Wednesday, April 13, 2011

With ActiveRecord has_many through relationships how do I delete associations while keeping objects

In Rails how do you delete a has-many through association while retaining the formerly associated objects? Is there an ActiveRecord way to do this or I do need to write the SQL?

Also is it possible for the objects to remain friends once the relationship is gone? [ <-- lame joke attempt]

From stackoverflow
  • Found it myself. collections.delete and just have to make sure dependents are not set to be deleted or destroyed. Somehow asking the question publicly seems to lead to me figuring the answer out in about 10 minutes on my own.

  • Somehow asking the question publicly seems to lead to me figuring the answer out in about 10 minutes on my own.

    That's because writing it down traverses a different neural pathway, one that apparently has other connections/associations in your mind.

0 comments:

Post a Comment