Class: Plugins::CamaSubscriber::ItemsController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/plugins/cama_subscriber/items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

#destroyObject



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

#editObject



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

#indexObject



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

#newObject



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

#showObject



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

#updateObject



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