On K, 2007-07-04 at 20:55 +1000, Daniel N wrote:

> I've been thinking about this issue myself and have thought of how I
> would like to use it, but I have not worked out how I could patch it.
> I hope I'm not way off the conversation here. ;) 
> 
> Basically I have been thinking that if a hash is passed to the
> conditions option whose keys are either the current table, or one of
> the included associations then the conditions for that association
> should be scoped appropriately 
> 
> eg.
> 
> User.find( :all, :include => :articles, :conditions => { :users    =>
> { :active => true } , 
>                                                                             
> :articles => {  :active => true,  
>                                                                               
>                   :published => true } } )
> 
> If the conditions hash is an array or does not include keys for active
> associations then it should behave as current. 
> User.find( :all, :include => :articles, :conditions => { :active =>
> true } ) #=> Should be scoped to user
> 
> Is this inline with what your saying?  Sorry if it's not.

Yes, though I still think that there should also be a fix
for this problem when using non-hash conditions because hash
can only do simple conditions (IS, IN, =, BETWEEN).

As for how to fix it, one way would be to extend the sanitize_sql
method  to do more pre- or post-processing on the query. It should
be possible to provide the real (aliased) table name to sanitize_sql.



--~--~---------~--~----~------------~-------~--~----~
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