Sha256: a372c8917f11c11df90a6a1ed50dad4613222cdcb3ae868c66bc52040ce784d5
Contents?: true
Size: 573 Bytes
Versions: 24
Compression:
Stored size: 573 Bytes
Contents
# Bugfix: building an sti model from an association fails # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti ActiveRecord::Reflection::AssociationReflection.class_eval do def build_association(*opts, &block) col = klass.inheritance_column.to_sym if !col.nil? && opts.first.is_a?(Hash) && (opts.first.symbolize_keys[col]) sti_model = opts.first.delete(col) sti_model.to_s.camelize.constantize.new(*opts, &block) else klass.new(*opts, &block) end end end
Version data entries
24 entries across 24 versions & 1 rubygems