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

Ticket #8727: ares_with_prefix_options_reload_fix.diff

File ares_with_prefix_options_reload_fix.diff, 1.2 kB (added by iwarshak, 2 years ago)
  • test/base_test.rb

    old new  
    293293    ryan = Person.new(:id => 1, :name => 'Ryan', :address => address) 
    294294    assert_equal address.prefix_options, ryan.address.prefix_options 
    295295  end 
     296   
     297  def test_reload_works_with_prefix_options 
     298    address = StreetAddress.find(1, :params => { :person_id => 1 }) 
     299    assert_equal address, address.reload 
     300  end 
     301   
     302  def test_reload_works_without_prefix_options     
     303    person = Person.find(:first) 
     304    assert_equal person, person.reload 
     305  end 
     306     
    296307 
    297308  def test_create 
    298309    rick = Person.create(:name => 'Rick') 
  • lib/active_resource/base.rb

    old new  
    294294 
    295295    # Reloads the attributes of this object from the remote web service. 
    296296    def reload 
    297       self.load(self.class.find(id, @prefix_options).attributes) 
     297      self.load(self.class.find(id, :params => @prefix_options).attributes) 
    298298    end 
    299299 
    300300    # Manually load attributes from a hash. Recursively loads collections of