> If I have two m:m models - posts and tags. > > How I do update their association automatically? > > Right now I am doing something like this: > > @post.comments.intermediaries.destroy > params[:comment_ids].each do |id| > @post.comments << Comment.get(id.to_i) > end > @post.save > > Note: "params[:comment_ids]" is collected via check boxes. > > Which means that, I need to wipe the existing association and > reconstruct it. I don't think it's very intuitive. Am I missing > something here?
You should be able to do something like this: @post.update(:comments => Comment.all(:id => params[:comment_ids])) If you aren't able to do this, I would consider it a bug and create a ticket (at http://is.gd/aa86) with a failing test case. -- Dan (dkubb) -- You received this message because you are subscribed to the Google Groups "DataMapper" 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/datamapper?hl=en.
