Вы можете очистить код с помощью named_scopes:
class Comment
named_scope :for_user, lambda { |user_id|
:conditions => ["comments.user_id = (?)", user_id]
}
named_scope :created_after, lambda { |time|
:conditions => ["comments.created_at > (?)", time]
}
# ... rest of class ...
end
, и тогда ваш запрос будет:
t = Time.local(2011, 8, 11)
comments_count = Comment.for_user(record.user_id).created_after(t).count()