I'm looking for a nice(!) way to specify multiple joins to the same
table where there are different conditions on each one.
I was hoping for something like this
class Model < ActiveRecord::Base
has_many :things
scope :some_things,
joins(:things).where('things.foo' => 'bar').
joins(:things => :others).where('others.foo' => 'baz')
end
Unfortunately, this is wishful thinking. As far as I can tell, I have to
write the SQL for the second join explicitly like this
joins('JOIN things AS others ON models.id = things.model_id')
Did I miss a better way?
Michael
--
Michael Schuerig
mailto:[email protected]
http://www.schuerig.de/michael/
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" 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-talk?hl=en.