Hi,
i’m fairly new to ruby on rails, and i know the question at hand may
seem simple at first, but i’m getting really caught up in trying to
understand this and the docs aren’t giving me answer. i actually thought
i knew how the sql commands work (like :include, :conditions, :etc) but
obviously, i don’t.
there are three models M1, M2, M3 joined by a habtam relashinship of
M1 has_and_belongs_to_many M2
M2 has_and_belongs_to_many M1
M2 has_and_belongs_to_many M3
M3 has_and_belongs_to_many M2
and a MyController which is the backbone of the site. (although i
haven’t specified exactly {model :M1} or something like that in the
controller, but as far as i know, that shouldn’t change anything [?]).
in MyController i have an action that selects rows from M1 with an
:include => ‘M2s’ and that changes the sql output to “outer left
join…etc” which is great. . . but when i want to add a :conditions
clause, i find that it doesn’t add the conditon correctly into the outer
left join sql command, and it ends up giving me an sql syntax error!
If i try to use the :conditions clause alone (without :include) , i get
no error, which is great.
but how do i get the two together?? isn’t it possible to put a
:condition on a select[habtam] action? am i missing something entirely,
or is there something small i am missing? maybe i need to define
something in the controller regarding the three models, or …???
i appreciate any help…
thanks.
harper