Class: Homesteading::Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Homesteading::Post
- Defined in:
- app/models/homesteading/post.rb
Instance Method Summary collapse
- #name ⇒ Object
- #params ⇒ Object
- #path ⇒ Object
- #post_type ⇒ Object
- #public? ⇒ Boolean
- #published_at ⇒ Object
Instance Method Details
#name ⇒ Object
33 34 35 |
# File 'app/models/homesteading/post.rb', line 33 def name [title, subtitle].compact.join(" : ") end |
#params ⇒ Object
25 26 27 |
# File 'app/models/homesteading/post.rb', line 25 def params { year: year, month: month, day: day, slug: slug } end |
#path ⇒ Object
15 16 17 18 19 |
# File 'app/models/homesteading/post.rb', line 15 def path base = ["/" + post_type] base += [year.to_s.rjust(2, "0"), month.rjust(2, "0"), day.rjust(2, "0"), slug] if published_at base.compact.join("/") end |
#post_type ⇒ Object
21 22 23 |
# File 'app/models/homesteading/post.rb', line 21 def post_type @post_type ||= Setting.where(name: "Post Type").first.content.downcase.pluralize end |
#public? ⇒ Boolean
29 30 31 |
# File 'app/models/homesteading/post.rb', line 29 def public? !self.private? end |
#published_at ⇒ Object
37 38 39 |
# File 'app/models/homesteading/post.rb', line 37 def published_at read_attribute(:published_at) || self.published_at = Time.zone.now end |