Class: Spotlight::GroupsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spotlight/groups_controller.rb

Overview

Base CRUD controller for groups

Instance Method Summary collapse

Instance Method Details

#create ⇒ Object

POST /exhibits/1/groups



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/spotlight/groups_controller.rb', line 20

def create
  @group.attributes = group_params

  if @group.save
    redirect_to(
      spotlight.exhibit_searches_path(anchor: 'browse-groups'),
      notice: t(:'helpers.submit.group.created', model: human_name)
    )
  else
    redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups')
  end
end

#destroy ⇒ Object

DELETE /groups/1



41
42
43
44
45
# File 'app/controllers/spotlight/groups_controller.rb', line 41

def destroy
  @group.destroy

  redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups'), alert: t(:'helpers.submit.group.destroyed', model: human_name)
end

#index ⇒ Object



11
12
13
14
15
16
17
# File 'app/controllers/spotlight/groups_controller.rb', line 11

def index
  respond_to do |format|
    format.json do
      render json: @groups.as_json, root: false
    end
  end
end

#update ⇒ Object

PATCH/PUT /groups/1



34
35
36
37
38
# File 'app/controllers/spotlight/groups_controller.rb', line 34

def update
  @group.update(group_params)

  redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups'), notice: t(:'helpers.submit.group.updated', model: human_name)
end

#update_all ⇒ Object



47
48
49
50
51
52
53
54
# File 'app/controllers/spotlight/groups_controller.rb', line 47

def update_all
  notice = if @exhibit.update update_all_group_params
             t(:'helpers.submit.group.batch_updated', model: human_name)
           else
             t(:'helpers.submit.group.batch_error', model: human_name)
           end
  redirect_to spotlight.exhibit_searches_path(anchor: 'browse-groups'), notice:
end