Module AttributeFu::Associations::ClassMethods
In: lib/attribute_fu/associations.rb

Methods

Public Instance methods

Behaves identically to the regular has_many, except adds the option :attributes, which, if true, creates a method called association_id_attributes (i.e. task_attributes, or comment_attributes) for setting the attributes of a collection of associated models.

The format is as follows:

    @project.task_attributes = {
      @project.tasks.first.id => {:title => "A new title for an existing task"},
      :new => {
        "0" => {:title => "A new task"}
      }
    }

Any existing tasks that are not present in the attributes hash will be removed from the association when the (parent) model is saved.

[Source]

    # File lib/attribute_fu/associations.rb, line 90
90:       def has_many_with_association_option(association_id, options = {}, &extension)
91:         unless (config = options.delete(:attributes)).nil?
92:           self.managed_association_attributes << association_id
93:         end
94:         
95:         has_many_without_association_option(association_id, options, &extension)
96:       end

[Validate]