This project is archived and is in readonly mode.

#5268 ✓ resolved
petRUShka

Rails3: find_by_property1_and_property2 for has_many associations was broken after upgrade to RC

Reported by petRUShka | August 1st, 2010 @ 09:12 PM

class City < ActiveRecord::Base
  has_many :locations, :dependent => :destroy
end

Common has_many association. Before upgrade to RC it was ok. But after upgrade:

irb(main):027:0> c = City.first
=> #<City id: 1, name: "belgorod", created_at: "2010-07-11 11:13:31", updated_at: "2010-07-11 11:13:31">
irb(main):030:0> c.locations.find_by_name_and_created_at "a", Time.now
=> nil
irb(main):031:0> c.locations.find_or_create_by_name_and_created_at "a", Time.now
NoMethodError: undefined method `find_by_nameandcreated_at' for []:Array
    from /usr/lib/ruby/gems/svn/gems/activerecord-3.0.0.rc/lib/active_record/associations/association_proxy.rb:154:in `send'
    from /usr/lib/ruby/gems/svn/gems/activerecord-3.0.0.rc/lib/active_record/associations/association_collection.rb:425:in `method_missing'
    from (irb):31
    from /usr/lib/ruby/gems/svn/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:44:in `start'
    from /usr/lib/ruby/gems/svn/gems/railties-3.0.0.rc/lib/rails/commands/console.rb:8:in `start'
    from /usr/lib/ruby/gems/svn/gems/railties-3.0.0.rc/lib/rails/commands.rb:23:in `<top (required)>'
    from script/rails:9:in `require'
    from script/rails:9:in `<main>'

ruby 1.9.3dev (2010-05-08 trunk 27674) [x86_64-linux]
Rails3.RC

Comments and changes to this ticket

Create your profile

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

Tickets have moved to Github

The new ticket tracker is available at https://github.com/rails/rails/issues

Shared Ticket Bins

People watching this ticket

Pages