DRY some Refinery::Blog::Post methods.
This commit is contained in:
parent
5ea1b7399b
commit
c9ff548329
1 changed files with 8 additions and 7 deletions
|
@ -72,23 +72,19 @@ module Refinery
|
||||||
end
|
end
|
||||||
|
|
||||||
def published_dates_older_than(date)
|
def published_dates_older_than(date)
|
||||||
where("published_at <= ?", date).pluck(:published_at)
|
published_before(date).pluck(:published_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
def live
|
|
||||||
where( "published_at <= ? and draft = ?", Time.now, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
def recent(count)
|
def recent(count)
|
||||||
live.limit(count)
|
live.limit(count)
|
||||||
end
|
end
|
||||||
|
|
||||||
def popular(count)
|
def popular(count)
|
||||||
unscoped.order("access_count DESC").limit(count)
|
unscoped.order("access_count DESC").limit(count)
|
||||||
end
|
end
|
||||||
|
|
||||||
def previous(item)
|
def previous(item)
|
||||||
where(["published_at < ? and draft = ?", item.published_at, false]).limit(1)
|
published_before(item.published_at).limit(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def uncategorized
|
def uncategorized
|
||||||
|
@ -101,6 +97,11 @@ module Refinery
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def published_before(date=Time.now)
|
||||||
|
where("published_at < ? and draft = ?", date, false)
|
||||||
|
end
|
||||||
|
alias_method :live, :published_before
|
||||||
|
|
||||||
def comments_allowed?
|
def comments_allowed?
|
||||||
Refinery::Setting.find_or_set(:comments_allowed, true, :scoping => 'blog')
|
Refinery::Setting.find_or_set(:comments_allowed, true, :scoping => 'blog')
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue