Module: ActiveRecord::JSONB::Associations::Association
- Defined in:
- lib/activerecord/jsonb/associations/association.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#create_scope ⇒ Object
rubocop:disable Metrics/AbcSize.
- #creation_attributes ⇒ Object
Instance Method Details
#create_scope ⇒ Object
rubocop:disable Metrics/AbcSize
18 19 20 21 22 23 24 25 |
# File 'lib/activerecord/jsonb/associations/association.rb', line 18 def create_scope super.tap do |scope| next unless .key?(:foreign_store) scope[[:foreign_store].to_s] ||= {} scope[[:foreign_store].to_s][reflection.foreign_key] = owner[reflection.active_record_primary_key] end end |
#creation_attributes ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/activerecord/jsonb/associations/association.rb', line 5 def creation_attributes return super unless reflection..key?(:foreign_store) attributes = {} jsonb_store = reflection.[:foreign_store] attributes[jsonb_store] ||= {} attributes[jsonb_store][reflection.foreign_key] = owner[reflection.active_record_primary_key] attributes end |