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_vho-3.0.31 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.30 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.29 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.28 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.27 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.26 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.25 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.26 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.25 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.24 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_clarity-3.0.24.2 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.23 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.22 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.24 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.21 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.23 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.22 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold-3.0.21 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.20 lib/active_scaffold/extensions/active_association_reflection.rb
active_scaffold_vho-3.0.19 lib/active_scaffold/extensions/active_association_reflection.rb