Module: Sequel::Plugins::NestedAttributes

Module | Sequel::Plugins::NestedAttributes
In: | lib/sequel/plugins/nested_attributes.rb

The nested_attributes plugin allows you to update attributes for associated objects directly through the parent object, similar to ActiveRecord‘s Nested Attributes feature.

Nested attributes are created using the nested_attributes method:

      Artist.one_to_many :albums
      Artist.nested_attributes :albums
      a = Artist.new(:name=>'YJM',
       :albums_attributes=>[{:name=>'RF'}, {:name=>'MO'}])
      # No database activity yet

      a.save # Saves artist and both albums
      a.albums.map{|x| x.name} # ['RF', 'MO']

### Methods

apply

### Classes and Modules

Module Sequel::Plugins::NestedAttributes::ClassMethods
Module Sequel::Plugins::NestedAttributes::InstanceMethods

### Public Class methods

apply(model)

Depend on the instance_hooks plugin.

[Source]

        # File lib/sequel/plugins/nested_attributes.rb, line 19
    19:       def self.apply(model)
    20:         model.plugin(:instance_hooks)
    21:       end

[Validate]