Sha256: 7cfa2cee223925827a43883e0bbfdcd95868ae8cf128e36dcfe067c0b0a415b7
Contents?: true
Size: 872 Bytes
Versions: 1
Compression:
Stored size: 872 Bytes
Contents
module ActiveRecord::Associations class HasManyForActiveModelAssociation < HasManyAssociation # remove conditions: owner.new_record?, foreign_key_present? def find_target? !loaded? && klass end # no dependent action def null_scope? false end # full replace simplely def replace(other_array) other_array.each { |val| raise_on_type_mismatch!(val) } target_ids = reflection.options[:target_ids] owner[target_ids] = other_array.map(&:id) end # no need load_target, and transaction def concat(*records) flatten_records = records.flatten flatten_records.each { |val| raise_on_type_mismatch!(val) } target_ids = reflection.options[:target_ids] owner[target_ids] ||= [] owner[target_ids].concat(flatten_records.map(&:id)) reset reset_scope end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
activemodel-associations-0.0.1 | lib/active_record/associations/has_many_for_active_model_association.rb |