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

Changeset 8090

Show
Ignore:
Timestamp:
11/06/07 18:33:45 (10 months ago)
Author:
marcel
Message:

Update XML documentation examples to include explicit type attributes. Closes #9754 [hasmanyjosh]

Files:

Legend:

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

    r7685 r8090  
     1* Update XML documentation examples to include explicit type attributes. Closes #9754 [hasmanyjosh] 
     2 
    13*2.0.0 [Preview Release]* (September 29th, 2007) 
    24 
  • trunk/activeresource/lib/active_resource/base.rb

    r7764 r8090  
    1515  # URI of the resources. 
    1616  #  
    17   #            class Person < ActiveResource::Base 
    18   #              self.site = "http://api.people.com:3000/" 
    19   #            end 
     17  #     class Person < ActiveResource::Base 
     18  #       self.site = "http://api.people.com:3000/" 
     19  #     end 
    2020  #  
    2121  # Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and 
     
    2727  # from REST web services. 
    2828  #  
    29   #    ryan = Person.new(:first => 'Ryan', :last => 'Daigle') 
    30   #    ryan.save  #=> true 
    31   #    ryan.id  #=> 2 
    32   #    Person.exists?(ryan.id)  #=> true 
    33   #    ryan.exists?  #=> true 
    34   #  
    35   #    ryan = Person.find(1) 
    36   #    # => Resource holding our newly create Person object 
    37   #  
    38   #    ryan.first = 'Rizzle' 
    39   #    ryan.save  #=> true 
    40   #  
    41   #    ryan.destroy  #=> true 
     29  #   ryan = Person.new(:first => 'Ryan', :last => 'Daigle') 
     30  #   ryan.save  #=> true 
     31  #   ryan.id  #=> 2 
     32  #   Person.exists?(ryan.id)  #=> true 
     33  #   ryan.exists?  #=> true 
     34  #  
     35  #   ryan = Person.find(1) 
     36  #   # => Resource holding our newly create Person object 
     37  #  
     38  #   ryan.first = 'Rizzle' 
     39  #   ryan.save  #=> true 
     40  #  
     41  #   ryan.destroy  #=> true 
    4242  # 
    4343  # As you can see, these are very similar to Active Record's lifecycle methods for database records. 
     
    4949  # defining your own custom REST methods. 
    5050  #  
    51   #   Person.new(:name => 'Ryan).post(:register)                                                
     51  #   Person.new(:name => 'Ryan).post(:register) 
    5252  #   # => { :id => 1, :name => 'Ryan', :position => 'Clerk' } 
    5353  # 
    54   #   Person.find(1).put(:promote, :position => 'Manager')              
     54  #   Person.find(1).put(:promote, :position => 'Manager') 
    5555  #   # => { :id => 1, :name => 'Ryan', :position => 'Manager' } 
    5656  #  
     
    6262  # You can validate resources client side by overriding validation methods in the base class. 
    6363  #  
    64   #            class Person < ActiveResource::Base 
    65   #               self.site = "http://api.people.com:3000/" 
    66   #               protected 
    67   #                 def validate 
    68   #                   errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/ 
    69   #                 end 
    70   #            end 
     64  #     class Person < ActiveResource::Base 
     65  #        self.site = "http://api.people.com:3000/" 
     66  #        protected 
     67  #          def validate 
     68  #            errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/ 
     69  #          end 
     70  #     end 
    7171  #  
    7272  # See the ActiveResource::Validations documentation for more information. 
     
    138138  #   # 
    139139  #   # Response (422): 
    140   #   # <errors><error>First cannot be empty</error></errors> 
     140  #   # <errors type="array"><error>First cannot be empty</error></errors> 
    141141  #   # 
    142142  # 
  • trunk/activeresource/README

    r7098 r8090  
    6161   # Expects a response of 
    6262   # 
    63    # <person><id>1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person> 
     63   # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person> 
    6464   # 
    6565   # for GET http://api.people.com:3000/people/1.xml 
     
    8989   # Expects a response of 
    9090   # 
    91    # <people
    92    #  <person><id>1</id><first>Ryan</first></person> 
    93    #  <person><id>2</id><first>Jim</first></person> 
     91   # <people type="array"
     92   #  <person><id type="integer">1</id><first>Ryan</first></person> 
     93   #  <person><id type="integer">2</id><first>Jim</first></person> 
    9494   # </people> 
    9595   #