Sha256: 49d347b786ebad41c7f8d49ea7d04f332481c76bde44bf88db0c99947e9df62e
Contents?: true
Size: 1022 Bytes
Versions: 27
Compression:
Stored size: 1022 Bytes
Contents
module Pageflow # Concern that can be included in entry type specific controllers # that extend the REST interface used by the editor. Handles # authentication, entry lookup, authorization and edit locking. # # @since 15.1 module EditorController extend ActiveSupport::Concern include EditLocking included do before_action :authenticate_user! before_action do begin @entry = DraftEntry.find(params[:entry_id]) rescue ActiveRecord::RecordNotFound head :not_found end end before_action do begin Ability.new(current_user).authorize!(:update, @entry.to_model) rescue CanCan::AccessDenied head :forbidden end end before_action :verify_edit_lock before_action do head :bad_request if params[:entry_type] && @entry.entry_type.name != params[:entry_type] end end private def verify_edit_lock verify_edit_lock!(@entry) end end end
Version data entries
27 entries across 27 versions & 1 rubygems