Sha256: dd5a7a0b0008342247c6d630501dae4c61b23f5b000108015829bdc2a308812f
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
module PageFactory module PagesControllerExtensions def self.included(base) base.class_eval do around_filter :set_page_factory, :only => :new before_filter { |c| c.include_stylesheet 'admin/dropdown' } before_filter { |c| c.include_javascript 'admin/dropdown' } before_filter { |c| c.include_javascript 'admin/pagefactory' } responses do |r| r.singular.default { set_page_defaults if 'new' == action_name } end end end def set_page_factory begin PageFactory.current_factory = params[:factory] rescue NameError => e # bad factory name passed logger.error "Tried to create page with invalid factory: #{e.message}" ensure yield PageFactory.current_factory = nil end end def set_page_defaults model.class_name = PageFactory.current_factory.page_class model.layout = Layout.find_by_name(PageFactory.current_factory.layout) model.page_factory = PageFactory.current_factory.name unless PageFactory::Base == PageFactory.current_factory end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
radiant-page_factory-extension-1.0.1 | lib/page_factory/pages_controller_extensions.rb |
radiant-page_factory-extension-1.0.0 | lib/page_factory/pages_controller_extensions.rb |