Class: Content
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Content
- Defined in:
- app/models/content.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_slug(slug, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/models/content.rb', line 9 def self.from_slug(slug, ={}) raise ArgumentError.new("You must provide a default text for a content.") if [:default].nil? find_or_initialize_by_slug(slug).tap do |content| if content.new_record? content.text = [:default] content.save end end end |
Instance Method Details
#parsed_text ⇒ Object
19 20 21 |
# File 'app/models/content.rb', line 19 def parsed_text markdown.to_html.html_safe end |
#raw_text ⇒ Object
23 24 25 |
# File 'app/models/content.rb', line 23 def raw_text text.html_safe end |