Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

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

#5268
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

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to resolved
    • Importance changed from to Low

    petRUShka this was fixed here http://github.com/rails/rails/commit/9d109302f139a23d18de6054540747...
    Try with the master code and let me know ;).
    Thanks for reporting the issue, though.

    August 2nd, 2010 @ 12:33 AM

  2. petRUShka
    petRUShka

    After upgrade to this commit all is ok :)

    Thanks.

    August 2nd, 2010 @ 08:48 AM