Using edge rails:

class User < ActiveRecord::Base
   has_many :locker_items
end

class LockerItem < ActiveRecord::Base
 belongs_to :user
 belongs_to :item
end

class Item < ActiveRecord::Base; end

user = User.find(1)

user.locker_items.count(:include => :item)
=> SELECT count(*) AS count_all FROM locker_items WHERE (locker_items.user_id = 1)

LockerItem.count(:include => :item, :conditions => ["user_id = ?", user.id])
=> SELECT count(DISTINCT locker_items.id) AS count_all FROM locker_items LEFT OUTER JOIN items ON items.id = locker_items.item_id WHERE (user_id=1)

These two queries should be identical, but the first seems to be ignoring the :include. Something must have changed recently as it did work previously. I'll look into it further, but can't dedicate any time to it this evening - hence the email!

Thanks.
_______________________________________________
Rails-core mailing list
Rails-core@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails-core

Reply via email to