Class: Content

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/content.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_slug(slug, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'app/models/content.rb', line 11

def from_slug(slug, options={})
  raise NoDefaultContentError if options[:default].nil?
  find_or_initialize_by_slug(slug).tap do |content|
    if content.new_record?
      content.name = slug
      content.text = options[:default]
      content.save
    end
  end
end

Instance Method Details

#parsed_textObject



7
8
9
# File 'app/models/content.rb', line 7

def parsed_text
  RDiscount.new(text).to_html.html_safe
end