Mixing new elements on submit #133

kinley opened this Issue Jan 12, 2012 · 2 comments

2 participants


I'm using nested_model in my form. Everything is ok: it's adding and removing elements, but when I click submit button, it mix the order of new added elements.
For example, I have
class Unit < ActiveRecord::Base
has_many :vocabulizers
accepts_nested_attributes_for :vocabulizers, :reject_if => lambda { |a| a[:word].blank? }, :allow_destroy => true

and I want to add Vocabulizer elements with word attributes 1,2 and 3
as a result I get:
Parameters: {"commit"=>"Сохранить и выйти", "authenticity_token"=>"v9tmU4HWiTO7PxNLV1frP9icY5A5eC1zZ7X2KkyMC/Y=", "utf8"=>"✓", "id"=>"64", "unit"=>{"price"=>"15", "title"=>"teste", "learning_module_id"=>"1",
{"new_1326353468552"=>{"usage"=>"", "word"=>"3", "translation"=>"", "_destroy"=>"false", "usage_t"=>""},
"0"=>{"usage"=>"", "word"=>"2", "id"=>"1152", "translation"=>"", "_destroy"=>"1", "usage_t"=>""},
"new_1326353464160"=>{"usage"=>"", "word"=>"1", "translation"=>"", "_destroy"=>"false", "usage_t"=>""},
"1"=>{"usage"=>"", "word"=>"3", "id"=>"1153", "translation"=>"", "_destroy"=>"1", "usage_t"=>""},
"2"=>{"usage"=>"", "word"=>"1", "id"=>"1154", "translation"=>"", "_destroy"=>"1", "usage_t"=>""},
"new_1326353466528"=>{"usage"=>"", "word"=>"2", "translation"=>"", "_destroy"=>"false", "usage_t"=>""}}, "theory"=>"


\r\n\tteset one more time

\r\n", "description"=>""}}

as you see, vocabulizer_attributes are mixed. why is it happens? And why it makes 6 elements instead of 3?


Is there still an issue? Could you please push a test application reproducing this issue?


Closing as it looks like a duplication of #37.

@lest lest closed this Sep 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment