Sha256: 2b273c8e3302e3558edb00efcf5d8274a7bf0bf084e3145fe0f5615a85b51f76
Contents?: true
Size: 1.36 KB
Versions: 18
Compression:
Stored size: 1.36 KB
Contents
module AdminIt # module Controller def self.included(base) base.class_eval do include Pundit if AdminIt::Env.pundit? before_filter :authenticate_user! attr_reader :context helper_method :context, :resource helper AdminIt::Helpers helper AdminIt::Engine.routes.url_helpers if AdminIt::Env.pundit? collections = @resource.collections.map(&:context_name) after_action :verify_authorized, except: collections after_action :verify_policy_scoped, only: collections end end end def resource self.class.instance_variable_get(:@resource) end def redirect_to_default if context.child? redirect_to(context.parent.class.url(context.parent, section: context.section)) else redirect_to(resource[resource.default_context].url) end end private def load_context(context_class) @context = context_class.new(self) yield if block_given? layout = ['admin_it', params[:layout]].compact.join('_') unless performed? if layout == 'admin_it' && !request.query_parameters.empty? redirect_to request.path else Request.get(request).process! render template: "admin_it/#{context.name}", layout: layout end end @context.save end end end
Version data entries
18 entries across 18 versions & 1 rubygems