Skip to content

Latest commit

 

History

History
13 lines (9 loc) · 496 Bytes

array_of_stored_models.md

File metadata and controls

13 lines (9 loc) · 496 Bytes

Array of stored models

Should you store an array of stored models, use #to_array_type method:

class Product < ApplicationRecord
  attribute :configurations, Configuration.to_array_type
end

After that, your attribute will return an array of Configuration instances.

Heads up! The attribute is not the same as the association, in this case–it's just a hash. assign_attributes (and similar) is going to override the whole hash, not merge it with a previous value.