venue_management/app/controllers/admin/venue_management_items_cont...

53 lines
1.4 KiB
Ruby

class Admin::VenueManagementItemsController < OrbitAdminController
def initialize
super
@app_title = 'venue_management'
end
def index
@venue_management_items = VenueManagementItem.all
@url = admin_venue_management_item_path(@venue_management_items)
end
def create
@venue_management_item = VenueManagementItem.new(venue_management_item_params)
@venue_management_item.save
redirect_to request.referer, :status => 303
end
def create_in_form
@venue_management_item = VenueManagementItem.new(venue_management_item_params)
@venue_management_item.savevenue_management_item
render :json => {:id=>@venue_management_item.id.to_s, :title=>@venue_management_item.title}.to_json ,:layout => false
end
def update
@venue_management_item = VenueManagementItem.find(params[:id])
@venue_management_item.update_attributes(venue_management_item_params)
redirect_to request.referer, :status => 303
end
def toggle
@venue_management_item = VenueManagementItem.find(params[:id])
@venue_management_item.save!
redirect_to request.referer, :status => 303
end
def delete_items
items = VenueManagementItem.find(params[:ids].split(',')) rescue nil
if items
items.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def venue_management_item_params
params.require(:venue_management_item).permit!
end
end