venue_management/app/controllers/admin/venue_management_item_conte...

71 lines
2.4 KiB
Ruby
Raw Permalink Normal View History

2020-05-07 15:26:34 +00:00
# encoding: utf-8
class Admin::VenueManagementItemContentsController < OrbitAdminController
before_action ->(module_app = @app_title) { set_variables module_app }
def initialize
super
@app_title = "venue_management"
end
def index
@venue_management_item_contents = VenueManagementItemContent.where(:venue_management_main_id => params[:venue_management_main_id]).page(params[:page]).per(10)
@venue_management = VenueManagementMain.find(params[:venue_management_main_id])
@venue_management_items = VenueManagementItem.where(:_id.nin=> VenueManagementItemContent.where(:venue_management_main_id => params[:venue_management_main_id]).collect{|t| t.venue_management_item_id} ).collect{|a| [a.title,a.id]}
end
def new
@contents = VenueManagementItemContent.where(:venue_management_main_id => params[:venue_management_main_id]).collect{|t| t.venue_management_item_id}
@venue_management_item_content = VenueManagementItemContent.new
@venue_management_items = VenueManagementItem.where(:_id.nin=> @contents).collect{|a| [a.title,a.id]}
end
def create
venue_management_item_content = VenueManagementItemContent.new(venue_management_item_content_params)
venue_management_item_content.create_user_id = current_user.id
venue_management_item_content.update_user_id = current_user.id
venue_management_item_content.save
redirect_to params['referer_url']+"?venue_management_main_id="+venue_management_item_content.venue_management_main_id
end
def edit
@venue_management_item_content = VenueManagementItemContent.find(params[:id])
@venue_management = VenueManagementMain.find(@venue_management_item_content.venue_management_main_id)
end
def update
@venue_management_item_content = VenueManagementItemContent.find(params[:id])
@venue_management_item_content.update_attributes(venue_management_item_content_params)
redirect_to "/admin/venue_management_item_contents?venue_management_main_id="+@venue_management_item_content.venue_management_main_id
end
def destroy
@venue_management_item_content = VenueManagementItemContent.find(params[:id])
@venue_management_item_content.destroy
redirect_to "/admin/venue_management_item_contents?venue_management_main_id="+@venue_management_item_content.venue_management_main_id
end
private
def venue_management_item_content_params
params.require(:venue_management_item_content).permit!
end
end