Sha256: 4b51f26f7d4f75db6cab1b8be32c0560baae4cb91d85a26a493f3b4bd2df88a5

Contents?: true

Size: 549 Bytes

Versions: 36

Compression:

Stored size: 549 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)
    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)
    else
      klass.new(*opts)
    end
  end
end

Version data entries

36 entries across 36 versions & 4 rubygems

Version Path
active_scaffold_san-3.0.18 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.18 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.17 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.16 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.15 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.14 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.13 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.12 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.11 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.12 lib/extensions/active_association_reflection.rb
active_scaffold-3.0.11 lib/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.10 lib/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.9 lib/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.8 lib/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.7 lib/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.6 lib/extensions/active_association_reflection.rb