Sha256: 1c7e1a9bdb9d71b7b349ea4b158c6aa12441f3565d258a1f10a3379d59f9756d
Contents?: true
Size: 961 Bytes
Versions: 15
Compression:
Stored size: 961 Bytes
Contents
# frozen_string_literal: true require 'active_support/concern' require 'active_record/associations' require 'active_record/associations/association' module BetterRecord module AssociationsExtensions module AssociationExtensions extend ActiveSupport::Concern included do def creation_attributes attributes = {} if (reflection.has_one? || reflection.collection?) && !options[:through] attributes[reflection.foreign_key] = owner[reflection.active_record_primary_key] if reflection.type attributes[reflection.type] = get_type_value end end attributes end def get_type_value BetterRecord::PolymorphicOverride.polymorphic_value(owner.class, reflection.options) end end end end end ActiveRecord::Associations::Association.send(:include, BetterRecord::AssociationsExtensions::AssociationExtensions)
Version data entries
15 entries across 15 versions & 1 rubygems