Sha256: a39d51bccf7f16069175ddbc4fb1137acb50ebd0eedf045a2e44bd6f10bd59b7
Contents?: true
Size: 1021 Bytes
Versions: 4
Compression:
Stored size: 1021 Bytes
Contents
module Pageable extend ActiveSupport::Concern included do before_filter :load_current_page end module ClassMethods def page(name, path, options = {}, &block) this_controller_name = "#{self.name.underscore}".gsub("_controller", "") uid = "#{this_controller_name}##{name}" i18n_scope = "pages.#{self.name.underscore.split('/').last}##{name}" parent = title = options.delete(:title) || I18n.t("#{i18n_scope}.title", :default => "#{name}".humanize) if Page.table_exists? page = Page.find_or_create_by_uid(uid, :title => title, :name => name) end map(name, path, options = {}, &block) @pages ||= [] @pages << "#{name}" end def pages @pages || [] end end def load_current_page if self.class.pages.include?(action_name) this_controller_name = "#{self.class.name.underscore}".gsub("_controller", "") @current_page = Page.find_by_uid("#{this_controller_name}##{action_name}") end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
fullstack-cms-0.1.5 | app/models/pageable.rb |
fullstack-cms-0.1.4 | app/models/pageable.rb |
fullstack-cms-0.1.3 | app/models/pageable.rb |
fullstack-cms-0.1.2 | app/models/pageable.rb |