hello,
this is probably a simple problem but I havn''t found the elegant/simple
RoR way to solve it.
I have a Parent and a Child table with a has_many :children and a belongs _to
:parent, relationship.
I view all childs through each parent this way:
<% for parent in Parent.find_all %>
parent.name parent.other_attribute
for child in parent.children
child.name child.age child activity etc
end
<% end %>
It works fine.
Now I want the same thing but with a condition in the child table. For example
only the children below a certain age (...WHERE children.age < 12 ) also if
the parent hasn''t got any children below 12 it musn''t appear.
If the condition lay in the parent it''s simple instead of :
Parent.find_all i put : Parent.find(:all, :conditions => "profession =
''doctor''"). But this Parent.find(:all, :conditions =>
"child.age < 12") does not.
My best guess is there would be a method in the model class Child <
ActiveRecord or maybe something with :join ...
thank you for your help
charly
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails