app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.0.0.alpha.2 vs app/controllers/spotlight/searches_controller.rb in blacklight-spotlight-3.0.0.alpha.3
- old
+ new
@@ -8,11 +8,11 @@
load_resource :exhibit, class: 'Spotlight::Exhibit'
before_action :authenticate_user!
before_action :only_curators!
before_action :create_or_load_resource, only: [:create]
load_and_authorize_resource through: :exhibit
- before_action :attach_breadcrumbs, only: [:index, :edit], unless: -> { request.format.json? }
+ before_action :attach_breadcrumbs, only: %i[index edit], unless: -> { request.format.json? }
include Spotlight::Base
include Spotlight::SearchHelper
def create
@@ -29,11 +29,11 @@
def index
respond_to do |format|
format.html
format.json do
- render json: @searches.as_json(methods: [:count, :thumbnail_image_url]), root: false
+ render json: @searches.as_json(methods: %i[count thumbnail_image_url]), root: false
end
end
end
def autocomplete
@@ -90,18 +90,18 @@
query_params = @search.query_params.with_indifferent_access
query_params.merge(q: params[:q])
end
def attach_breadcrumbs
- e = @exhibit || (@search.exhibit if @search)
+ e = @exhibit || @search&.exhibit
add_breadcrumb t(:'spotlight.exhibits.breadcrumb', title: e.title), e
add_breadcrumb t(:'spotlight.curation.sidebar.header'), exhibit_dashboard_path(e)
add_breadcrumb t(:'spotlight.curation.sidebar.browse'), exhibit_searches_path(e)
end
def batch_search_params
- params.require(:exhibit).permit('searches_attributes' => [:id, :published, :weight])
+ params.require(:exhibit).permit('searches_attributes' => %i[id published weight])
end
def search_params
params.require(:search).permit(
:title,
@@ -116,25 +116,25 @@
def query_params
params.to_unsafe_h.with_indifferent_access.except(:exhibit_id, :search, *blacklisted_search_session_params).reject { |_k, v| v.blank? }
end
def featured_image_params
- [
- :iiif_region, :iiif_tilesource,
- :iiif_manifest_url, :iiif_canvas_id, :iiif_image_id,
- :display,
- :source,
- :image,
- :document_global_id
+ %i[
+ iiif_region iiif_tilesource
+ iiif_manifest_url iiif_canvas_id iiif_image_id
+ display
+ source
+ image
+ document_global_id
]
end
def only_curators!
authorize! :curate, @exhibit if @exhibit
end
def blacklisted_search_session_params
- [:id, :commit, :counter, :total, :search_id, :page, :per_page, :authenticity_token, :utf8, :action, :controller]
+ %i[id commit counter total search_id page per_page authenticity_token utf8 action controller]
end
def fallback_url
spotlight.exhibit_searches_path(current_exhibit)
end