Sha256: 812187d38ce8ffc530a8fb4d9f33eb22a0cf4ee1d4f978833cb2bd3bcef58069
Contents?: true
Size: 631 Bytes
Versions: 11
Compression:
Stored size: 631 Bytes
Contents
module Superstore module Associations class HasMany < Association def reader unless loaded? self.target = load_collection end target end def writer(records) relation = load_collection # TODO: Use relation.load_records with Rails 5 relation.instance_variable_set :@records, records relation.instance_variable_set :@loaded, true self.target = relation end private def load_collection association_class.where(reflection.foreign_key => owner.try(reflection.primary_key)) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems