venue_management/app/controllers/admin/venue_management_memorabili...

60 lines
1.8 KiB
Ruby
Raw Normal View History

2020-08-04 09:04:04 +00:00
class Admin::VenueManagementMemorabiliasController < Admin::VenueAdminController
2020-07-30 14:28:57 +00:00
include Admin::VenueManagementsHelper
before_action ->(module_app = @app_title) { set_variables module_app }
before_action :set_venue_management_memorabilia, only: [:edit, :update, :destroy]
def initialize
super
@app_title = 'venue_management'
end
def index
@table_fields = [
'venue_management.title',
'vm_memorabilia.case_no',
'vm_memorabilia.event_date',
'vm_memorabilia.details',
]
@memorabilias = VenueManagementMemorabilia.order(updated_at: :desc).page(params[:page]).per(10)
end
def new
@venue_management = VenueManagementMain.find(params[:id])
2020-08-02 13:33:41 +00:00
@venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_main_id: params[:id])
2020-07-30 14:28:57 +00:00
end
def create
@venue_management_memorabilia = VenueManagementMemorabilia.new(venue_management_memorabilia_params)
@venue_management_memorabilia.save
redirect_to params['referer_url']
end
def edit
@venue_management = VenueManagementMain.find(@venue_management_memorabilia.venue_management_main_id)
end
def update
@venue_management_memorabilia.update_attributes(venue_management_memorabilia_params)
redirect_to venue_management_memorabilias_admin_venue_management_path(@venue_management_memorabilia.venue_management_main_id)
end
def destroy
@venue_management_main_id = @venue_management_memorabilia.venue_management_main_id
@venue_management_memorabilia.destroy
redirect_to venue_management_memorabilias_admin_venue_management_path(@venue_management_main_id)
end
private
def set_venue_management_memorabilia
@venue_management_memorabilia = VenueManagementMemorabilia.find(params[:id])
end
def venue_management_memorabilia_params
params.require(:venue_management_memorabilia).permit!
end
end