Class: Spotlight::RolesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/spotlight/roles_controller.rb

Instance Method Summary collapse

Methods included from Controller

#blacklight_config, #current_exhibit, #exhibit_search_action_url, #exhibit_search_facet_url, #search_action_url, #search_facet_url

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#indexObject



7
8
9
10
11
12
13
14
# File 'app/controllers/spotlight/roles_controller.rb', line 7

def index
  role = @exhibit.roles.build
  authorize! :edit, role
  
  add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: @exhibit.title), @exhibit
  add_breadcrumb t(:'spotlight.administration.sidebar.header'), exhibit_dashboard_path(@exhibit)
  add_breadcrumb t(:'spotlight.administration.sidebar.users'), exhibit_roles_path(@exhibit)
end

#update_allObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/spotlight/roles_controller.rb', line 16

def update_all
  attrs = params.require(:exhibit).permit(:roles_attributes => [:id, :user_key, :role, :_destroy])

  any_deleted = authorize_nested_attributes(attrs[:roles_attributes], Role)

  if @exhibit.update(attrs)
    notice = any_deleted > 0 ? t(:'helpers.submit.role.destroyed') : t(:'helpers.submit.role.updated')
    redirect_to exhibit_roles_path(@exhibit), notice: notice 
  else
    flash[:alert] = t(:'helpers.submit.role.batch_error')
    render action: 'index'
  end

end