public
Description: Rails Plugin: Populate associations using primitive instances (hashes, arrays) instead of class instances
Clone URL: git://github.com/duncanbeevers/populate_association_lazily.git
name age message
file .gitignore Tue Jun 10 17:23:31 -0700 2008 Ignore generated files [duncanbeevers]
file README Mon Jul 14 10:08:01 -0700 2008 Added deprecation notice. [duncanbeevers]
file Rakefile Tue Jun 10 17:18:08 -0700 2008 Initial check-in [duncanbeevers]
file init.rb Fri Jun 13 12:39:12 -0700 2008 Hooks for polymorphic behavior mixing [duncanbeevers]
directory lib/ Fri Jun 27 23:02:26 -0700 2008 Allow updating already-populated association wi... [duncanbeevers]
directory test/ Fri Jun 27 23:02:26 -0700 2008 Allow updating already-populated association wi... [duncanbeevers]
README
Deprecated
This behavior is available in rails core as of commit e0750d6a5c7f621e4ca12205137c0b135cab444a
http://github.com/rails/rails/commit/e0750d6a5c7f621e4ca12205137c0b135cab444a

Allows creation of objects through associations by assigning hash to association

  class User < ActiveRecord::Base
    has_one :wristband
    has_many :favorites
    has_many :favorite_wristbands, :through => :favorites, :source => :wristband
  end

  class Wristband < ActiveRecord::Base
    belongs_to :user
  end

  class Favorite < ActiveRecord::Base
    belongs_to :user
    belongs_to :wristband
  end

  user = User.new(:wristband => { :color => 'orange' })

  user = User.new(:favorite_wristbands => [ { :color => 'pink' } ] )