Allow extjs to use NestedAttributes in ActiveRecord models.
This behaviour has been extracted from NestedAttributes module.
As an example:
class Book < ActiveRecord::Base
has_many :pages
accepts_nested_attributes_extjs_for :pages
end
book.pages_attributes = attributes
# Where attributes can be
{
"ext-record-1" => {
"number" => "1",
...
},
"ext-record-2" => {
"number" => "2",
...
},
3 => {
"number" => "30",
}
}
It means that we are creating 2 new pages for the book (“1” and “2”) and updating the page whose id is 3 to have the number “30”. All the other pages will be removed from the book (This is a very important thing to have in mind).
We can se that keys like “ext-record-…” appears in the hash when a new element is going to be created. That is so because Extjs doesn’t allow arrays in the parameters (well, we could encode the array in a JSON object, but it isn’t the purpose of this plugin).
-
Clean the code to remove some methods posibly repeated from nested_attributes
-
Tests