Module | Sequel::Plugins::NestedAttributes::InstanceMethods |
In: |
lib/sequel/plugins/nested_attributes.rb
|
Set the nested attributes for the given association. obj should be an enumerable of multiple objects for plural associations. The opts hash can be used to override any of the default options set by the class-level nested_attributes call.
# File lib/sequel/plugins/nested_attributes.rb, line 137 137: def set_nested_attributes(assoc, obj, opts=OPTS) 138: raise(Error, "no association named #{assoc} for #{model.inspect}") unless ref = model.association_reflection(assoc) 139: raise(Error, "nested attributes are not enabled for association #{assoc} for #{model.inspect}") unless meta = ref[:nested_attributes] 140: meta = meta.merge(opts) 141: meta[:reflection] = ref 142: if ref.returns_array? 143: nested_attributes_list_setter(meta, obj) 144: else 145: nested_attributes_setter(meta, obj) 146: end 147: end