Ruby on Rails Friday, March 30, 2012

Thanks for trying to decipher my problem. I may have made an error in my description of the problem.


Regardless, after much digging, what I am looking for is not currently possible.
https://github.com/rails/rails/issues/919

On Friday, March 30, 2012 6:43:47 AM UTC-7, Tim Shaffer wrote:
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/-/1aJeX0CWqkoJ.
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