Sha256: e6b150d7f735164ffb984e18c0f3433eb93c79856df6553fdfef47193869b580
Contents?: true
Size: 638 Bytes
Versions: 1
Compression:
Stored size: 638 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 = load_collection end private def load_collection association_class.where(reflection.foreign_key => owner.try(reflection.primary_key)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
superstore-2.0.1 | lib/superstore/associations/has_many.rb |