Forum: Ruby on Rails Save only working on New objects

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E614185be23ba875c541320104dc4a7f?d=identicon&s=25 Bob Mr. (regmonkey)
on 2009-05-16 06:34
I'm using a habtm self referential (below). When I work with it in the
console, if I do this:

  memberA.friends[0] = memberB
  memberA.save

Nothing actually gets saved to the join table. (memberA and memberB are
previously saved objects).

If, however, I do this:

  memberA.friends[0] = Member.new     // the new object here is the
difference
  memberA.save

the relationship Does get saved to the join table.

Anyone have a clue as to why this is? And how I can get changes to
previously saved objects to save to the sql join table?

Thanks!
This topic is locked and can not be replied to.