Class: Spotlight::FiltersController

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

Overview

Create and update filters for an exhibit

Instance Method Summary collapse

Methods included from Concerns::ApplicationController

#enabled_in_spotlight_view_type_configuration?, #field_enabled?

Methods included from Controller

#blacklight_config, #current_exhibit, #current_masthead, #current_masthead=, #current_site, #default_url_options, #exhibit_masthead?, #exhibit_search_action_url, #exhibit_search_facet_url, #resource_masthead?, #search_action_url, #search_facet_url, #set_exhibit_locale_scope, #set_locale

Methods included from Config

#exhibit_specific_blacklight_config

Instance Method Details

#createObject



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

def create
  if @filter.save
    flash[:notice] = t('helpers.submit.filter.updated', model: @filter.model_name.human)
  else
    flash[:alert] = @filter.errors.full_messages.join('<br/>'.html_safe)
  end
  redirect_to spotlight.edit_exhibit_path @exhibit, tab: 'filter'
end

#filter_paramsObject



24
25
26
# File 'app/controllers/spotlight/filters_controller.rb', line 24

def filter_params
  params.require(:filter).permit(:field, :value)
end

#updateObject



17
18
19
20
21
22
# File 'app/controllers/spotlight/filters_controller.rb', line 17

def update
  unless @filter.update(filter_params)
    flash[:alert] = @filter.errors.full_messages.join('<br/>'.html_safe)
  end
  redirect_to spotlight.edit_exhibit_path @exhibit, tab: 'filter'
end