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

Changeset 6703

Show
Ignore:
Timestamp:
05/09/07 03:51:06 (1 year ago)
Author:
rick
Message:

Handle string and symbol param keys when splitting params into prefix params and query params.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activeresource/CHANGELOG

    r6646 r6703  
    11*SVN* 
     2 
     3* Handle string and symbol param keys when splitting params into prefix params and query params. 
     4 
     5    Comment.find(:all, :params => { :article_id => 5, :page => 2 }) or Comment.find(:all, :params => { 'article_id' => 5, :page => 2 }) 
    26 
    37* Added find-one with symbol [DHH]. Example: Person.find(:one, :from => :leader) # => GET /people/leader.xml 
  • trunk/activeresource/lib/active_resource/base.rb

    r6657 r6703  
    216216 
    217217          (options || {}).each do |key, value| 
    218             (prefix_parameters.include?(key) ? prefix_options : query_options)[key] = value 
     218            next if key.blank? 
     219            (prefix_parameters.include?(key.to_sym) ? prefix_options : query_options)[key.to_sym] = value 
    219220          end 
    220221 
     
    361362        if response['Content-size'] != "0" && response.body.strip.size > 0 
    362363          load(connection.xml_from_response(response)) 
    363         end         
     364        end 
    364365      end 
    365366 
  • trunk/activeresource/test/base_test.rb

    r6657 r6703  
    110110  def test_custom_element_path 
    111111    assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1) 
     112    assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1) 
    112113  end 
    113114 
    114115  def test_custom_element_path_with_parameters 
    115116    assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :person_id => 1, :type => 'work') 
     117    assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, 'person_id' => 1, :type => 'work') 
    116118    assert_equal '/people/1/addresses/1.xml?type=work', StreetAddress.element_path(1, :type => 'work', :person_id => 1) 
    117119    assert_equal '/people/1/addresses/1.xml?type%5B%5D=work&type%5B%5D=play+time', StreetAddress.element_path(1, :person_id => 1, :type => ['work', 'play time']) 
     
    124126  def test_custom_collection_path 
    125127    assert_equal '/people/1/addresses.xml', StreetAddress.collection_path(:person_id => 1) 
     128    assert_equal '/people/1/addresses.xml', StreetAddress.collection_path('person_id' => 1) 
    126129  end 
    127130 
    128131  def test_custom_collection_path_with_parameters 
    129132    assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path(:person_id => 1, :type => 'work') 
     133    assert_equal '/people/1/addresses.xml?type=work', StreetAddress.collection_path('person_id' => 1, :type => 'work') 
    130134  end 
    131135