Sha256: dfeb8c73eae965aac3aa942047c543799d80fef1eba03edab951936f2d63f5ed
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
module Spotlight class ResourcesController < Spotlight::ApplicationController before_filter :authenticate_user!, except: [:show] load_and_authorize_resource :exhibit, class: Spotlight::Exhibit before_filter :build_resource, only: [:create] load_and_authorize_resource through: :exhibit helper_method :from_popup? def new @resource.attributes = resource_params if params[:resource] @resource = @resource.becomes_provider ## TODO: in Rails 4.1, replace this with a variant if from_popup? render layout: 'spotlight/popup' else render end end def create @resource.attributes = resource_params @resource = @resource.becomes_provider if @resource.save if from_popup? render layout: false, text: "<html><script>window.close();</script></html>" else redirect_to admin_exhibit_catalog_index_path(@resource.exhibit) end else render action: 'new' end end protected def resource_params params.require(:resource).permit(:url) end def build_resource @resource ||= @exhibit.resources.build(resource_params).becomes_provider end def from_popup? params.fetch(:popup, false) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
blacklight-spotlight-0.2.0 | app/controllers/spotlight/resources_controller.rb |