Can you be more specific about what your model associations look like?
What I would suggest is trying to come up with a way to push all of
this logic down to mysql, so basically you would want to query
straight from the Muscle model. Muscle.find(:all, :conditions =>
"", :include => :muscle_groups), etc. I dunno the exact details of
your database but a good combination of :include or :join should solve
your issue. Have a look at the documentation in rails and look at your
development logs to see what queries are being generated when you hit
the view to get an idea of what everything is doing.

On Nov 28, 11:51 am, Seb <[email protected]> wrote:
> exercise hm:t muscles
>
> In my controller I do @muscle_groups = MuscleGroup.all
>
> Then in my view I do
> - @muscle_groups.each do |mg|
>   - mg.muscles.all(:conditions => ["id not in (?)",
> @exercise.muscle_ids]).each do |m|
>     ...
>
> I'm trying to filter out all the muscles already added to an exercise.
> However this is clear bad practice. Since all this should be happening
> in the controller (prehaps even in the model?)
>
> So how do I go about filtering my active record based on values by
> association? if that makes sense...
>
> best regards,
> Seb

--

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.


Reply via email to