Ruby on Rails Friday, March 30, 2012

I am a little confused here. If ModelB belongs to ModelA, I think your foreign key relationship is backwards. The model_b_table should have a foreign key to model_a_id, not the other way around.


Regardless, though, you can pass conditions to delete_all which should help you accomplish what you want.

ModelA.delete_all("model_b_id is null")

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/yCvn0kpKbqwJ.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment