rails/rails — Issue #4423: There is no good way to import nested serialized data
Author: Svensklanemarknad
Created: 2012-01-12 15:20:34+00:00
State: open

One option to solve this is by fixing the export. Add the following line in activemodel/lib/active_model/serialization.rb:

```ruby
serializable_add_includes(options) do |association, records, opts|
+ association = association + "_attributes" if association.to_sym.in?(class.nested_attributes_options.keys) and opts[:nested_attributes]
hash[association] = if records.is_a?(Enumerable)
records.map { |a| a.serializable_hash(opts) }
else
records.serializable_hash(opts)
end
end
```