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