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 18 |
# 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.name = slug content.text = [:default] content.save end end end |
Instance Method Details
#parsed_text ⇒ Object
20 21 22 |
# File 'app/models/content.rb', line 20 def parsed_text markdown.to_html.html_safe end |
#raw_text ⇒ Object
24 25 26 |
# File 'app/models/content.rb', line 24 def raw_text text.html_safe end |