Class: Homesteading::Post

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/homesteading/post.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



33
34
35
# File 'app/models/homesteading/post.rb', line 33

def name
  [title, subtitle].compact.join(" : ")
end

#paramsObject



25
26
27
# File 'app/models/homesteading/post.rb', line 25

def params
  { year: year, month: month, day: day, slug: slug }
end

#pathObject



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_typeObject



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

Returns:

  • (Boolean)


29
30
31
# File 'app/models/homesteading/post.rb', line 29

def public?
  !self.private?
end

#published_atObject



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