Class: PandaCms::Post
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- PandaCms::Post
- Defined in:
- app/models/panda_cms/post.rb
Instance Method Summary collapse
- #excerpt(length = 100, squish: true) ⇒ Object
- #formatted_slug ⇒ Object
- #path ⇒ Object
- #to_param ⇒ Object
Instance Method Details
#excerpt(length = 100, squish: true) ⇒ Object
40 41 42 43 44 |
# File 'app/models/panda_cms/post.rb', line 40 def excerpt(length = 100, squish: true) excerpt = post_content.to_plain_text excerpt = excerpt.squish if squish excerpt.truncate(length).html_safe end |
#formatted_slug ⇒ Object
50 51 52 53 54 55 56 |
# File 'app/models/panda_cms/post.rb', line 50 def formatted_slug if slug[0] == "/" slug[1, slug.length].to_s else slug end end |
#path ⇒ Object
46 47 48 |
# File 'app/models/panda_cms/post.rb', line 46 def path "/" + PandaCms.config.posts[:prefix] + slug.to_s end |
#to_param ⇒ Object
36 37 38 |
# File 'app/models/panda_cms/post.rb', line 36 def to_param formatted_slug.to_s end |