Displaying 1 result from an estimated 1 matches for "my_company".
Did you mean:
__company
2007 Apr 04
1
[PLUGIN] count_from_query - easily convert finder queries into count queries
...f 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 it be
converted into a count query.
Association proxies work the same way. We could change the
complete_videos definition to be
class Company < ActiveRecord::Base
def complete_videos
videos.find :all, :conditions =>...