Skip to content

Commit

Permalink
Adding Finder Method to utilize count
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekOnCoffee committed May 20, 2012
1 parent f4b647c commit 67a177f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/refinery/blog/category.rb
Expand Up @@ -14,7 +14,7 @@ class Category < ActiveRecord::Base
attr_accessible :title

def post_count
posts.select(&:live?).count
posts.live.count
end

# how many items to show per page
Expand Down
4 changes: 4 additions & 0 deletions app/models/refinery/blog/post.rb
Expand Up @@ -48,6 +48,10 @@ def live?
!draft and published_at <= Time.now
end

def live
where(["published_at <= ? and draft = ?", Time.now, false])
end

def friendly_id_source
custom_url.present? ? custom_url : title
end
Expand Down

0 comments on commit 67a177f

Please sign in to comment.