Class: Article
Instance Attribute Summary
Attributes inherited from Content
#draft
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Content
#author_id=, #category_titles, #draft?, find_sti_class, #just_published?, #owner, #owners, #pending?, primary, #published?, #published_at=, #published_at?, #published_month, #published_year, #state, #to_param
included
included
Class Method Details
.locale ⇒ Object
8
9
10
|
# File 'app/models/article.rb', line 8
def locale
"en"
end
|
Instance Method Details
#full_permalink ⇒ Object
32
33
34
35
36
37
|
# File 'app/models/article.rb', line 32
def full_permalink
raise "cannot create full_permalink for an article that belongs to a non-blog section" unless section.is_a?(Blog)
date = [:year, :month, :day].map { |key| [key, (published? ? published_at : created_at).send(key)] }.flatten
Hash[:permalink, permalink, *date]
end
|
#has_excerpt? ⇒ Boolean
27
28
29
30
|
# File 'app/models/article.rb', line 27
def has_excerpt?
return false if excerpt == "<p> </p>" excerpt.present?
end
|
#next ⇒ Object
Also known as:
next_article
22
23
24
|
# File 'app/models/article.rb', line 22
def next
section.articles.published.where(["#{self.class.table_name}.published_at > ?", published_at]).reorder(published_at: :asc).first
end
|
#previous ⇒ Object
Also known as:
previous_article
17
18
19
|
# File 'app/models/article.rb', line 17
def previous
section.articles.published.where(["#{self.class.table_name}.published_at < ?", published_at]).reorder(published_at: :desc).first
end
|
#primary? ⇒ Boolean
13
14
15
|
# File 'app/models/article.rb', line 13
def primary?
self == section.articles.primary
end
|