#29 ✓resolved
user296 (at gmail)

rails 2.3.3 and has_many

Reported by user296 (at gmail) | July 21st, 2009 @ 03:42 AM

I found a problem with has_many on rails 2.3.3 (bug not present in 2.3.2).
Given the following models :

  Dentist < ActiveRecord::Base
    has_many :patients
  end

  Patient < ActiveRecord::Base
  end

and then on the console:

Loading development environment (Rails 2.3.3)
>> d = Dentist.new
=> #<Dentist id: nil, name: nil>
>> d.save
=> true
>> d.patients
ArgumentError: wrong number of arguments (2 for 1)
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:173:in `sanitize_sql'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:173:in `send'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:173:in `sanitize_sql'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:41:in `find'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:399:in `find_target'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:353:in `load_target'
    from /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:139:in `inspect'
    from /usr/lib/ruby/1.8/irb.rb:302:in `output_value'
    from /usr/lib/ruby/1.8/irb.rb:151:in `eval_input'
    from /usr/lib/ruby/1.8/irb.rb:263:in `signal_status'
    from /usr/lib/ruby/1.8/irb.rb:147:in `eval_input'
    from /usr/lib/ruby/1.8/irb.rb:146:in `eval_input'
    from /usr/lib/ruby/1.8/irb.rb:70:in `start'
    from /usr/lib/ruby/1.8/irb.rb:69:in `catch'
    from /usr/lib/ruby/1.8/irb.rb:69:in `start'
    from /usr/local/bin/irb:13

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

ActiveRecord::Extension (aka ar-extensions) is a plugin to extend and
enhance the functionality of ActiveRecord. It starts by adding better
find support for ActiveRecord. It then adds mass data import
capabilities which are highly efficient and lastly it supports to_csv
functionality.

It also introduces a cool concept of creating easily extendable pieces
of ActiveRecord functionality, so developers don't have to understand
ActiveRecord internals or have the fear of breaking ActiveRecord
itself.

People watching this ticket

Tags

Pages