Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Mixing new elements on submit #133

Closed
tuykin opened this issue Jan 12, 2012 · 2 comments
Closed

Mixing new elements on submit #133

tuykin opened this issue Jan 12, 2012 · 2 comments
Labels

Comments

@tuykin
Copy link

tuykin commented Jan 12, 2012

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
end

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",
"vocabulizers_attributes"=>
{"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\tеуеуыуеыуфпфукпукп</p>\r\n

\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?

@lest
Copy link
Collaborator

lest commented Aug 28, 2012

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

@lest
Copy link
Collaborator

lest commented Sep 19, 2012

Closing as it looks like a duplication of #37.

@lest lest closed this as completed Sep 19, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants