Class: Plugins::CamaSubscriber::ItemsController
- Inherits:
-
AdminController
- Object
- AdminController
- Plugins::CamaSubscriber::ItemsController
- Defined in:
- app/controllers/plugins/cama_subscriber/items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 17 def create @item = current_site.subscriber_items.create(item_params) @item.add_groups(params[:groups]) flash[:notice] = t('.saved', default: 'The subscription was saved') redirect_to action: :index end |
#destroy ⇒ Object
42 43 44 45 46 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 42 def destroy @item = current_site.subscriber_items.find(params[:id]).destroy flash[:notice] = t('.destroyed', default: 'The subscription was destroyed') redirect_to action: :index end |
#edit ⇒ Object
24 25 26 27 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 24 def edit @item ||= current_site.subscriber_items.find(params[:id]) render 'form', layout: false end |
#index ⇒ Object
2 3 4 5 6 7 8 9 10 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 2 def index if params[:group].present? @group = current_site.subscriber_groups.find(params[:group]) @items = @group.items else @items = current_site.subscriber_items end @items = @items.paginate(:page => params[:page], :per_page => current_site.admin_per_page) end |
#new ⇒ Object
12 13 14 15 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 12 def new @item = current_site.subscriber_items.new render 'form', layout: false end |
#show ⇒ Object
37 38 39 40 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 37 def show @item = current_site.subscriber_items.find(params[:id]) render layout: false end |
#update ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/controllers/plugins/cama_subscriber/items_controller.rb', line 29 def update @item = current_site.subscriber_items.find(params[:id]) @item.update(item_params) @item.add_groups(params[:groups]) flash[:notice] = t('.updated', default: 'The subscription was udpated') redirect_to action: :index end |