Adding Finder Method to utilize count
This commit is contained in:
parent
f4b647cc93
commit
67a177fbb1
2 changed files with 5 additions and 1 deletions
|
@ -14,7 +14,7 @@ module Refinery
|
||||||
attr_accessible :title
|
attr_accessible :title
|
||||||
|
|
||||||
def post_count
|
def post_count
|
||||||
posts.select(&:live?).count
|
posts.live.count
|
||||||
end
|
end
|
||||||
|
|
||||||
# how many items to show per page
|
# how many items to show per page
|
||||||
|
|
|
@ -48,6 +48,10 @@ module Refinery
|
||||||
!draft and published_at <= Time.now
|
!draft and published_at <= Time.now
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def live
|
||||||
|
where(["published_at <= ? and draft = ?", Time.now, false])
|
||||||
|
end
|
||||||
|
|
||||||
def friendly_id_source
|
def friendly_id_source
|
||||||
custom_url.present? ? custom_url : title
|
custom_url.present? ? custom_url : title
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue