This project is archived and is in readonly mode.

#855 ✓wontfix
Thijs de Vries

HABTM creates duplicate row on push

Reported by Thijs de Vries | August 18th, 2008 @ 10:11 PM | in 2.x

Say I have two classes, foo and bar which have and belong to many of each other.

foo < ActiveRecord::Base has_and_belongs_to_many :bars end

bar < ActiveRecord::Base has_and_belongs_to_many :foos end

I use the appropriate join table bars_foos. If I do

foo = Foo.find(1); foo.bars.push(Bar.find(1)); foo.bars.push(Bar.find(1));

two rows will be added into the bars_foos database with foo_id = 1 and bar_id = 1

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages