Ahoy!

I've got two patches in Trac that fix cases where the finder for a has_many
association works with :include but it's count() fails.

http://dev.rubyonrails.org/ticket/9167
http://dev.rubyonrails.org/ticket/9175

Both are small, well-tested and fix existing features without adding new
ones.

Could some folks take a look at them?

Descriptions included below in case you'd prefer to read about them here.

Thanks,
::Jack Danger


When defining an association like the following:
Author < ActiveRecord::Base
  has_many :posts_with_no_comments, :class_name => 'Post', :conditions => '
comments.id is null', :include => :comments
end

The find() works. What doesn't work is asking for the size of the
association before it's been cached.
@author.posts_with_no_comments.size # => ERROR
@author.posts_with_no_comments # => [#<Post ... >, #<Post ... >]

It's a tiny patch - the association just needs to pass along the :include
option to the count method.

http://dev.rubyonrails.org/ticket/9175

For this simple has_many association:
class Author; has_many :posts; end
This works:
@author.posts.find(:all, :include => :comments, :conditions =>
'comments.idis null')
This fails:
@author.posts.count(:all, :include => :comments, :conditions =>
'comments.idis null')

The fix is to not clobber the :include option that gets passed explicitly.
It's a two-character patch.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to