Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4996: through-has-one-1.23.patch

File through-has-one-1.23.patch, 1.2 kB (added by chewi, 3 years ago)
  • activerecord/lib/active_record/reflection.rb

    old new  
    195195            raise HasManyThroughAssociationPolymorphicError.new(active_record.name, self, source_reflection) 
    196196          end 
    197197           
    198           unless [:belongs_to, :has_many].include?(source_reflection.macro) && source_reflection.options[:through].nil? 
     198          unless [:belongs_to, :has_many, :has_one].include?(source_reflection.macro) && source_reflection.options[:through].nil? 
    199199            raise HasManyThroughSourceAssociationMacroError.new(self) 
    200200          end 
    201201        end 
     
    212212              options[:source_type] || source_reflection.class_name 
    213213            else 
    214214              class_name = name.to_s.camelize 
    215               class_name = class_name.singularize if [ :has_many, :has_and_belongs_to_many ].include?(macro) 
     215              class_name = class_name.singularize if [ :has_one, :has_many, :has_and_belongs_to_many ].include?(macro) 
    216216              class_name 
    217217            end 
    218218          end