Class: OnboardOnRails::Admin::ToursController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- OnboardOnRails::ApplicationController
- BaseController
- OnboardOnRails::Admin::ToursController
- Defined in:
- app/controllers/onboard_on_rails/admin/tours_controller.rb
Instance Method Summary collapse
- #copy ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from BaseController
Instance Method Details
#copy ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 44 def copy copied = TourCopier.call(@tour) if copied.persisted? redirect_to edit_admin_tour_path(copied), notice: t(".success") else redirect_to admin_tours_path, alert: t(".failure") end end |
#create ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 15 def create @tour = Tour.new(tour_params) if @tour.save redirect_to admin_tour_path(@tour), notice: t("onboard_on_rails.flash.tour_created") else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
39 40 41 42 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 39 def destroy @tour.destroy redirect_to admin_tours_path, notice: t("onboard_on_rails.flash.tour_deleted") end |
#edit ⇒ Object
28 29 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 28 def edit end |
#index ⇒ Object
6 7 8 9 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 6 def index @tours = Tour.order(updated_at: :desc) @tours = @tours.where(status: params[:status]) if params[:status].present? end |
#new ⇒ Object
11 12 13 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 11 def new @tour = Tour.new end |
#show ⇒ Object
24 25 26 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 24 def show redirect_to edit_admin_tour_path(@tour) end |
#update ⇒ Object
31 32 33 34 35 36 37 |
# File 'app/controllers/onboard_on_rails/admin/tours_controller.rb', line 31 def update if @tour.update(tour_params) redirect_to edit_admin_tour_path(@tour), notice: t("onboard_on_rails.flash.tour_updated") else render :edit, status: :unprocessable_entity end end |