Sha256: 05e97ef72857f5f7f1a0bf26a818fe8a966f23253aee9d731eb096fcf9bc134b
Contents?: true
Size: 542 Bytes
Versions: 3
Compression:
Stored size: 542 Bytes
Contents
require 'gem-patching' # Make build associations have their given type # i.e.: site.sections.build(:type => 'Page').class == Page # http://pragmatig.com/2010/06/04/fixing-rails-nested-attributes-on-collections-with-sti Gem.patching('rails', '3.0.3') do class ActiveRecord::Reflection::AssociationReflection def build_association(*options) if options.first.is_a?(Hash) && options.first[:type].present? options.first[:type].to_s.constantize.new(*options) else klass.new(*options) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
adva-core-0.0.9 | lib/patches/rails/sti_associations.rb |
adva-core-0.0.8 | lib/patches/rails/sti_associations.rb |
adva-core-0.0.7 | lib/patches/rails/sti_associations.rb |