Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1378 (closed defect: wontfix)

Opened 4 years ago

Last modified 4 years ago

[XPATCH] When using push_with_attributes AR uses associations id as id in joins table

Reported by: pelle@neubia.com Assigned to: David
Priority: normal Milestone:
Component: ActiveRecord Version: 0.12.1
Severity: normal Keywords:
Cc:

Description

If your joins table has it's own id column and you try to do a push_with_attributes eg:

group.members.push_with_attributes(@newuser,:some_value=>XXX)

The join record will use the id from @newuser. This is obviouslly wrong.

In this patch I simplly filter any "id" attributes when building the sql.

Attachments

habtm_remove_joined_id_column.diff (0.7 kB) - added by pelle@neubia.com on 05/31/05 01:25:34.

Change History

05/31/05 01:25:34 changed by pelle@neubia.com

  • attachment habtm_remove_joined_id_column.diff added.

05/31/05 14:08:51 changed by nzkoz

  • priority changed from high to normal.
  • severity changed from critical to normal.
  • summary changed from When using push_with_attributes AR uses associations id as id in joins table to [XPATCH] When using push_with_attributes AR uses associations id as id in joins table.

Thanks for the patch, I'm having a little trouble understanding why you'd need this? Why do you need to have an ID on your join table?

push_with_attributes is a little lacking at present, and in most cases you should have an association class (i.e. GroupMember in your case). This lets you update the attributes and have behaviour in the right place rather than scattered around Group and User.

This particular 'feature' has been well known for a while, but I can't find it mentioned in the documentation, could you please take the patch against SVN rails rather than the gems? Once you've done that, switch the XPATCH to PATCH in the summary

06/10/05 18:38:37 changed by nzkoz

  • status changed from new to closed.
  • resolution set to wontfix.

This limitation is documented, so I'm going to close this ticket.