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.

Fix options hash mutation in AssociationCollection

#947

Reusing a hash of options for multiple finder queries on an association is problematic as the inputted options hash becomes mutated by #find. Attached patch simply dups the input to make the options hash recyclable.

@@@ruby options = { :order => 'updated_at desc' } Section.first.articles.find(:all, options) options # => => {:order=>"updated_at desc, created_at desc", :conditions=>"articles.section_id = 2", :limit=>nil, :select=>nil, :group=>nil, :joins=>nil, :readonly=>nil, :offset=>nil, :include=>:_route}


Reported by Brennan Dunn · August 31st, 2008 @ 11:30 PM

State: wontfix
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Brennan Dunn
    Brennan Dunn

    Messed up formatting.

    
    options = { :order => 'updated_at desc' }
    Section.first.articles.find(:all, options)
    options # => {:order=>"updated_at desc, created_at desc", :conditions=>"`articles`.section_id = 2", :limit=>nil, :select=>nil, :group=>nil, :joins=>nil, :readonly=>nil, :offset=>nil, :include=>:_route}
    

    August 31st, 2008 @ 11:32 PM

  2. Pratik
    Pratik
    • State changed from new to wontfix

    This is the same behavior as AR::Base.find(). You should just call .dup yourself before you supply find() with a hash.

    Thanks.

    December 20th, 2008 @ 05:02 PM