On Tue, Jul 15, 2008 at 8:42 PM, Michael Koziarski
<[EMAIL PROTECTED]> wrote:
>
>> Person.find(:all, :conditions => { :university => victoria_wellington })
>>
>
> I'm quite suspicious where you're using find_by_some_association,
> couldn't you be walking the associations back in the other direction.
>
> victoria_wellington.people
>
You could, but that's less easy when you've got other conditions. It's
just meant to replace:
Person.find(:all, :conditions => { :university_id => victoria_wellington })
Rails will automatically use the id for "victoria_wellington", but it
seems weird to say "_id" in the hash when you _actually_ mean the
association. And it gets even weirder when your foreign keys aren't
named the same as your association.
>> I'm planning on making it work for belongs_to and has_one (including
>> polymorphic association).
>
> How are you planning on making it work for has_one, what would the
> query look like?
At first it seemed hard as the has_one has to query against a seperate
table, but Pratik introduced a patch that allows you to specify
multiple tables in the conditions hash. I was planning on using that,
but I'll freely admit I haven't looked into it properly yet ;)
>> The discussion was basically around whether or not we should tie hash
>> conditions to the database field names.
>>
>> There was also some discussion about find_by_association, i.e
>>
>> Person.find_by_university(victoria_wellington)
>>
>> Josh has a patch that I can merge into all this stuff pretty easily.
>>
>> Pratik asked me to restart the discussion here, so I'd be interested
>> to hear what everybody thinks.
>
> I'd be a little concerned about adding some special case code to the
> sanitize_sql logic, but if some work was undertaken to rationalise all
> that stuff at the same time then this kind of thing could be a nice
> addition.
What kind of rationalisation needs to happen? I'm happy to take some of that on.
>
> Good stuff
>
> --
> Cheers
>
> Koz
>
> >
>
--
Nik Wakelin
+64 27 424 5433
* Blog: http://codetocustomer.com/blog
* WWR: http://workingwithrails.com/person/7401-nicholas-wakelin
* Company: http://codetocustomer.com
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---