app/controllers/spotlight/pages_controller.rb in blacklight-spotlight-3.0.0.alpha.2 vs app/controllers/spotlight/pages_controller.rb in blacklight-spotlight-3.0.0.alpha.3
- old
+ new
@@ -6,11 +6,11 @@
# rubocop:disable Metrics/ClassLength
# Disableing class length because this is a base
# controller that gives other controllers their behavior
class PagesController < Spotlight::ApplicationController
before_action :authenticate_user!, except: [:show]
- before_action :load_locale_specific_page, only: [:destroy, :edit, :show, :update]
+ before_action :load_locale_specific_page, only: %i[destroy edit show update]
load_and_authorize_resource :exhibit, class: Spotlight::Exhibit
load_and_authorize_resource through: :exhibit, instance_name: 'page', only: [:index]
helper Openseadragon::OpenseadragonHelper
include Spotlight::SearchHelper
@@ -69,11 +69,11 @@
end
end
# PATCH/PUT /pages/1
def update
- @page.lock.delete if @page.lock
+ @page.lock&.delete
if @page.update(page_params.merge(last_edited_by: current_user))
redirect_to [spotlight, @page.exhibit, @page], flash: { html_safe: true }, notice: undo_notice(:updated)
else
render action: 'edit'
@@ -144,21 +144,21 @@
def start_new_search_session?
params[:action] == 'show'
end
def page_attributes
- [:id, :published, :title, :weight, :display_sidebar, :parent_page_id]
+ %i[id published title weight display_sidebar parent_page_id]
end
def allowed_page_params
[:title, :content, thumbnail_attributes: featured_image_attributes]
end
def featured_image_attributes
- [
- :source, :image, :document_global_id, :iiif_region, :iiif_tilesource,
- :iiif_manifest_url, :iiif_canvas_id, :iiif_image_id
+ %i[
+ source image document_global_id iiif_region iiif_tilesource
+ iiif_manifest_url iiif_canvas_id iiif_image_id
]
end
def human_name
@human_name ||= page_collection_name.humanize
@@ -186,10 +186,10 @@
private
def update_all_page_params
params.require(:exhibit).permit(
- pages_attributes: [:id, :published]
+ pages_attributes: %i[id published]
)
end
def breadcrumb_to_exhibit_root(key)
add_breadcrumb t(key, title: current_exhibit.title), spotlight.exhibit_root_path(current_exhibit)