engine/app/controllers/admin/base_controller.rb
2010-04-24 02:32:36 +02:00

27 lines
623 B
Ruby

class Admin::BaseController < ::ApplicationController
include Locomotive::Routing::SiteDispatcher
layout 'admin'
before_filter :authenticate_account!
before_filter :require_site
helper_method :sections
protected
def self.sections(main, sub = nil)
write_inheritable_attribute(:sections, { :main => main, :sub => sub })
end
def sections(key = nil)
if !key.nil? && key.to_sym == :sub
self.class.read_inheritable_attribute(:sections)[:sub] || self.controller_name.dasherize
else
self.class.read_inheritable_attribute(:sections)[:main]
end
end
end