Class: EtabliocmsPages::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- EtabliocmsPages::Page
- Defined in:
- app/models/etabliocms_pages/page.rb
Instance Attribute Summary collapse
-
#attachment_data ⇒ Object
Returns the value of attribute attachment_data.
-
#child_of ⇒ Object
Returns the value of attribute child_of.
Instance Method Summary collapse
- #build_contents_for_available_locales ⇒ Object
- #content ⇒ Object
- #locales ⇒ Object
- #other_pages_for_select ⇒ Object
- #path ⇒ Object
- #titles ⇒ Object
- #to_param ⇒ Object
Instance Attribute Details
#attachment_data ⇒ Object
Returns the value of attribute attachment_data.
10 11 12 |
# File 'app/models/etabliocms_pages/page.rb', line 10 def @attachment_data end |
#child_of ⇒ Object
Returns the value of attribute child_of.
10 11 12 |
# File 'app/models/etabliocms_pages/page.rb', line 10 def child_of @child_of end |
Instance Method Details
#build_contents_for_available_locales ⇒ Object
46 47 48 49 50 |
# File 'app/models/etabliocms_pages/page.rb', line 46 def build_contents_for_available_locales I18n.available_locales.each do |available_locale| contents.build(:locale => available_locale) unless contents.map(&:locale).include?(available_locale.to_s) end end |
#content ⇒ Object
5 6 7 |
# File 'app/models/etabliocms_pages/page.rb', line 5 def content contents.where(:locale => I18n.locale).first end |
#locales ⇒ Object
36 37 38 |
# File 'app/models/etabliocms_pages/page.rb', line 36 def locales contents.map(&:locale).join(", ") end |
#other_pages_for_select ⇒ Object
40 41 42 43 44 |
# File 'app/models/etabliocms_pages/page.rb', line 40 def other_pages_for_select pages = EtabliocmsPages::Page.order("lft ASC") pages = pages.where("id != ?", id) unless new_record? pages.map { |d| ["#{' '*2*d.level}#{d.titles}".html_safe, d.id] } end |
#path ⇒ Object
24 25 26 |
# File 'app/models/etabliocms_pages/page.rb', line 24 def path self_and_ancestors.map{|p| p.slug }.join("/") end |
#titles ⇒ Object
32 33 34 |
# File 'app/models/etabliocms_pages/page.rb', line 32 def titles contents.map(&:title).join(" / ") end |
#to_param ⇒ Object
28 29 30 |
# File 'app/models/etabliocms_pages/page.rb', line 28 def to_param path end |