Class: Manuscript::Page
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Manuscript::Page
- Defined in:
- lib/manuscript/page.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.find_by_path(path) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/manuscript/page.rb', line 16 def self.find_by_path(path) page_names = path.split("/") @page = self.main_pages.find_by_name(page_names.delete_at(0)) raise ActiveRecord::RecordNotFound unless @page unless page_names.blank? page_names.each do |page_name| @page = @page.child_pages.find_by_name(page_name) raise ActiveRecord::RecordNotFound unless @page end end @page end |
Instance Method Details
#parent_url ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/manuscript/page.rb', line 37 def parent_url if parent parent.url else "" end end |
#to_html(user = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/manuscript/page.rb', line 45 def to_html(user = nil) if template template.render({'current_user' => user, 'contents' => RDiscount.new(contents).to_html}) else RDiscount.new(contents).to_html end end |
#url ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/manuscript/page.rb', line 29 def url if parent "#{parent.url}/#{name}" else "/#{name}" end end |