This project is archived and is in readonly mode.

#2032 ✓wontfix
jbarket (at sleepunit)

Support for String Lists in Mass Assignment of Associations via assocation_ids=

Reported by jbarket (at sleepunit) | February 21st, 2009 @ 12:16 AM | in 2.x

Currently, ActiveRecord's assocation_name_ids= will eat multiple ids if they're passed in a single string such as ["1,2,3,4"].

When it sees the array, it takes the first position ("1,2,3,4") and calls to_i. This drops everything after the first noninteger character, which means that only the first id value makes it through.

This can be a desired effect for people who do things like rewrite ids to humanize them (210-United-States) because it will still assassinated the unnecessary parts, but for this particular format for this particular method, it seems appropriate.

When nesting a habtm association inside of another form (object[assocation_ids]), ExtJS and others return the format mentioned above.

This patch looks for that format and translates it into what Rails actually wants.

Comments and changes to this ticket

  • cainlevy

    cainlevy February 21st, 2009 @ 07:39 PM


    This doesn't seems like a standard parameter format, nor one that should be standard. And the patch is tiny, yes, but I'd be disinclined to support non-standard ExtJS formats in core.

    Have you considered overriding your own association_ids= setter, or creating an association_ids_for_ext_js= setter? This also seems easily doable as a plugin, if you're concerned about redundant coding.

  • jbarket (at sleepunit)

    jbarket (at sleepunit) February 21st, 2009 @ 08:07 PM

    After discussing this one the mailing list and on IRC, I'm pretty sure you're right. Even though it's harmless, the only other way I see it coming up is stupidity, and I don't want the patch to reward laziness, heh.

    I think integrating it into an ExtJS plugin I'm already fond of is probably the way to go. I could even try and simply override it in JavaScript then.


  • Eloy Duran

    Eloy Duran February 22nd, 2009 @ 04:41 PM

    • State changed from “new” to “wontfix”

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=""></a>

People watching this ticket