Class: Publinator::Section
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Publinator::Section
- Defined in:
- app/models/publinator/section.rb
Class Method Summary collapse
-
.get_by_site_id_and_slug(site_id, section_name) ⇒ Object
current_site.id, params.
- .matches?(request) ⇒ Boolean
Instance Method Summary collapse
- #child_sections ⇒ Object
- #generate_section_slug ⇒ Object
- #index_item ⇒ Object
- #menu_collection ⇒ Object
- #parent_section ⇒ Object
- #path ⇒ Object
- #publishable ⇒ Object
- #publishables ⇒ Object
Class Method Details
.get_by_site_id_and_slug(site_id, section_name) ⇒ Object
current_site.id, params
19 20 21 |
# File 'app/models/publinator/section.rb', line 19 def self.get_by_site_id_and_slug(site_id, section_name) Section.find(:first, :conditions => ["site_id = ? and name = ?", site_id, section_name]) end |
.matches?(request) ⇒ Boolean
13 14 15 16 |
# File 'app/models/publinator/section.rb', line 13 def self.matches?(request) pt = self.find(:first, :conditions => ["section_slug = ?", request.path_parameters[:section]]) return pt.present? end |
Instance Method Details
#child_sections ⇒ Object
47 48 49 |
# File 'app/models/publinator/section.rb', line 47 def child_sections Section.where(:parent_id => id) end |
#generate_section_slug ⇒ Object
43 44 45 |
# File 'app/models/publinator/section.rb', line 43 def generate_section_slug self.section_slug = name.strip.downcase.gsub(/[^a-zA-Z0-9\-\_]/, '_') if section_slug.blank? end |
#index_item ⇒ Object
23 24 25 |
# File 'app/models/publinator/section.rb', line 23 def index_item Publinator::Publication.find_by_section_id_and_slug(id, 'index') end |
#menu_collection ⇒ Object
31 32 33 |
# File 'app/models/publinator/section.rb', line 31 def publications + child_sections end |
#parent_section ⇒ Object
51 52 53 |
# File 'app/models/publinator/section.rb', line 51 def parent_section Section.where(:id => parent_id).first if parent_id end |
#path ⇒ Object
27 28 29 |
# File 'app/models/publinator/section.rb', line 27 def path "/#{section_slug}" end |
#publishable ⇒ Object
35 36 37 |
# File 'app/models/publinator/section.rb', line 35 def publishable self end |
#publishables ⇒ Object
39 40 41 |
# File 'app/models/publinator/section.rb', line 39 def publishables publications end |