seminar/app/controllers/admin/seminar_items_controller.rb

53 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2016-06-29 06:57:45 +00:00
class Admin::SeminarItemsController < OrbitAdminController
def initialize
super
@app_title = 'seminar'
end
def index
@seminar_items = SeminarItem.all
@url = admin_seminar_item_path(@seminar_items)
end
def create
@seminar_item = SeminarItem.new(seminar_item_params)
@seminar_item.save
redirect_to request.referer, :status => 303
end
def create_in_form
@seminar_item = SeminarItem.new(seminar_item_params)
@seminar_item.saveseminar_item
render :json => {:id=>@seminar_item.id.to_s, :title=>@seminar_item.title}.to_json ,:layout => false
end
def update
@seminar_item = SeminarItem.find(params[:id])
@seminar_item.update_attributes(seminar_item_params)
redirect_to request.referer, :status => 303
end
def toggle
@seminar_item = SeminarItem.find(params[:id])
@seminar_item.save!
redirect_to request.referer, :status => 303
end
def delete_items
items = SeminarItem.find(params[:ids].split(',')) rescue nil
if items
items.each(&:destroy)
end
redirect_to request.referer, :status => 303
end
private
def seminar_item_params
params.require(:seminar_item).permit!
end
end