Created
August 29, 2008 18:46
-
-
Save batasrki/8031 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
# Blog related | |
def last_posts(published_only = false, limit = MAX_BLOG_ENTRIES) | |
conditions = nil | |
conditions = 'draft=false' if published_only | |
self.posts.find(:all, :select => 'id, title, preview, draft, created_at', | |
:conditions => conditions, :limit => limit, | |
:order => "created_at DESC") | |
end | |
def posts_count(published_only) | |
if published_only then self.published_posts.count else self.posts.count end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment