Class: Post
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Post
show all
- Defined in:
- app/models/post.rb
Constant Summary
collapse
- @@per_page =
5
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_by_permalink_or_id(param) ⇒ Object
27
28
29
|
# File 'app/models/post.rb', line 27
def self.find_by_permalink_or_id(param)
Post.find_by_permalink(param) || Post.find(param)
end
|
.types ⇒ Object
22
23
24
25
|
# File 'app/models/post.rb', line 22
def self.types
Dir[File.expand_path('../posts',__FILE__)+'/*.rb'].each { |f| require_dependency f }
self.subclasses.collect(&:to_s).sort
end
|
Instance Method Details
#asset ⇒ Object
14
15
16
|
# File 'app/models/post.rb', line 14
def asset
assets.first
end
|
54
55
56
|
# File 'app/models/post.rb', line 54
def format_published_at
self.published_at = Time.now if self.published_at.nil?
end
|
#title ⇒ Object
38
39
40
|
# File 'app/models/post.rb', line 38
def title
read_attribute(:title).blank? ? "Post #{id}" : read_attribute(:title)
end
|
#to_param ⇒ Object
18
19
20
|
# File 'app/models/post.rb', line 18
def to_param
permalink.blank? ? id.to_s : permalink
end
|