Changeset 8090
- Timestamp:
- 11/06/07 18:33:45 (10 months ago)
- Files:
-
- trunk/activeresource/CHANGELOG (modified) (1 diff)
- trunk/activeresource/lib/active_resource/base.rb (modified) (5 diffs)
- trunk/activeresource/README (modified) (2 diffs)
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 1 3 *2.0.0 [Preview Release]* (September 29th, 2007) 2 4 trunk/activeresource/lib/active_resource/base.rb
r7764 r8090 15 15 # URI of the resources. 16 16 # 17 # class Person < ActiveResource::Base18 # self.site = "http://api.people.com:3000/"19 # end17 # class Person < ActiveResource::Base 18 # self.site = "http://api.people.com:3000/" 19 # end 20 20 # 21 21 # Now the Person class is mapped to RESTful resources located at <tt>http://api.people.com:3000/people/</tt>, and … … 27 27 # from REST web services. 28 28 # 29 # ryan = Person.new(:first => 'Ryan', :last => 'Daigle')30 # ryan.save #=> true31 # ryan.id #=> 232 # Person.exists?(ryan.id) #=> true33 # ryan.exists? #=> true34 # 35 # ryan = Person.find(1)36 # # => Resource holding our newly create Person object37 # 38 # ryan.first = 'Rizzle'39 # ryan.save #=> true40 # 41 # ryan.destroy #=> true29 # 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 42 42 # 43 43 # As you can see, these are very similar to Active Record's lifecycle methods for database records. … … 49 49 # defining your own custom REST methods. 50 50 # 51 # Person.new(:name => 'Ryan).post(:register) 51 # Person.new(:name => 'Ryan).post(:register) 52 52 # # => { :id => 1, :name => 'Ryan', :position => 'Clerk' } 53 53 # 54 # Person.find(1).put(:promote, :position => 'Manager') 54 # Person.find(1).put(:promote, :position => 'Manager') 55 55 # # => { :id => 1, :name => 'Ryan', :position => 'Manager' } 56 56 # … … 62 62 # You can validate resources client side by overriding validation methods in the base class. 63 63 # 64 # class Person < ActiveResource::Base65 # self.site = "http://api.people.com:3000/"66 # protected67 # def validate68 # errors.add("last", "has invalid characters") unless last =~ /[a-zA-Z]*/69 # end70 # end64 # 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 71 71 # 72 72 # See the ActiveResource::Validations documentation for more information. … … 138 138 # # 139 139 # # Response (422): 140 # # <errors ><error>First cannot be empty</error></errors>140 # # <errors type="array"><error>First cannot be empty</error></errors> 141 141 # # 142 142 # trunk/activeresource/README
r7098 r8090 61 61 # Expects a response of 62 62 # 63 # <person><id >1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person>63 # <person><id type="integer">1</id><attribute1>value1</attribute1><attribute2>..</attribute2></person> 64 64 # 65 65 # for GET http://api.people.com:3000/people/1.xml … … 89 89 # Expects a response of 90 90 # 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> 94 94 # </people> 95 95 #