-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
I am running on the master branch with rails 4. I found that the update_attributes always empties the associations' ids array
I set up two models, Entry and EntryAlias, with HABTM relation. The Entry model can create multiple EntryAlias through nested form.
accepts_nested_attributes_for :entry_aliases, :allow_destroy => true
Here is the parameters passing to the @entry.update_attributes(entry_params).
Unable to find source-code formatter for language: hash. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
## entry_params {"content"=>" ", "open"=>"1", "entry_aliases_attributes"=>{"0"=>{"id"=>"51db0cf181e0e7585f000007", "name"=>"test", "_destroy"=>"false"}}}
After updating @entry, the entry_ids array in the origin EntryAlias is emptied
Unable to find source-code formatter for language: hash. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
## Original entry_alias { _id: ObjectId("51dafe4481e0e7f989000005"), entry_ids: [ ObjectId("51db013481e0e73d46000003") ], name: "test" } ## entry_alias after updating entry { _id: ObjectId("51db0cf181e0e7585f000007"), entry_ids: [], name: "test" }