Displaying 1 result from an estimated 1 matches for "videos_count".
2007 Apr 04
1
[PLUGIN] count_from_query - easily convert finder queries into count queries
...d} AND
status=''complete''", :order => "created_at DESC"
end
end
Getting the count isn''t quite as easy. You could just call #size on
the returned array, but it''s wasteful if you don''t actually need the
records. You could write a complete_videos_count method, but it
doesn''t feel very DRY to have two methods every time you want to do a
count query as well.
With count_from_query, it''s cake
videos_count = ActiveRecord::Base.count_from_query {
my_company.complete_videos }
You can wrap any AR find call in count_from_query to have...