method
    
    collection_accessor_methods
 
  collection_accessor_methods(reflection, association_proxy_class, writer = true)
  private
  
    Hide source    
    
      
  
# File activerecord/lib/active_record/associations.rb, line 1508 def collection_accessor_methods(reflection, association_proxy_class, writer = true) collection_reader_method(reflection, association_proxy_class) if writer redefine_method("#{reflection.name}=") do |new_value| # Loads proxy class instance (defined in collection_reader_method) if not already loaded association = send(reflection.name) association.replace(new_value) association end redefine_method("#{reflection.name.to_s.singularize}_ids=") do |new_value| pk_column = reflection.primary_key_column ids = (new_value || []).reject { |nid| nid.blank? } ids.map!{ |i| pk_column.type_cast(i) } send("#{reflection.name}=", reflection.klass.find(ids).index_by{ |r| r.id }.values_at(*ids)) end end end

 RSpec
RSpec Ruby on Rails
Ruby on Rails Ruby
Ruby 
   
    
 
   
   
   = protected
 = protected
  