Sha256: dcf33069b5968a6bc5aa205d293ab00a71fb1a21a9e1a641c68de1264993eb8a

Contents?: true

Size: 926 Bytes

Versions: 18

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

module Spotlight
  # Create and update filters for an exhibit
  class FiltersController < ApplicationController
    before_action :authenticate_user!
    load_and_authorize_resource :exhibit, class: 'Spotlight::Exhibit'
    load_and_authorize_resource through: :exhibit

    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

    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

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
blacklight-spotlight-3.0.0.alpha.2 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-3.0.0.alpha.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.13.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.12.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.12.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.11.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.10.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.9.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.8.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.7.2 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.7.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.7.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.6.1.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.6.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.6.0 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.5.2 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.5.1 app/controllers/spotlight/filters_controller.rb
blacklight-spotlight-2.5.0 app/controllers/spotlight/filters_controller.rb