diff options
author | Vishnu Atrai <vishnu.atrai@gmail.com> | 2011-08-01 20:48:45 +0530 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2011-08-04 16:41:29 -0700 |
commit | 163533b17d968d23eef0023e4c93338d5357d022 (patch) | |
tree | 6a747cd22814a5dbfda957a1e0432792f4f971f7 /railties/guides/source | |
parent | abfbab2713211dc6094165a1bb74fde5c17c2a74 (diff) | |
download | rails-163533b17d968d23eef0023e4c93338d5357d022.tar.gz rails-163533b17d968d23eef0023e4c93338d5357d022.tar.bz2 rails-163533b17d968d23eef0023e4c93338d5357d022.zip |
Active Resource - guide for create
Diffstat (limited to 'railties/guides/source')
-rw-r--r-- | railties/guides/source/active_resource_basics.textile | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/railties/guides/source/active_resource_basics.textile b/railties/guides/source/active_resource_basics.textile index 8a36622814..e40ca4fc42 100644 --- a/railties/guides/source/active_resource_basics.textile +++ b/railties/guides/source/active_resource_basics.textile @@ -34,13 +34,22 @@ Read requests use the GET method and expect the JSON form of whatever resource/r <ruby> # Find a person with id = 1 -ryan = Person.find(1) +person = Person.find(1) # Check if a person exists with id = 1 Person.exists?(1) # => true # Get all resources of Person class Person.all </ruby> +h4. Create + +Creating a new resource submits the JSON form of the resource as the body of the request with HTTP POST method and parse the response into Active Resource object. + +<ruby> +person = Person.create(:name => 'Vishnu') +person.id # => 1 +</ruby> + h3. Changelog * July 30, 2011: Initial version by "Vishnu Atrai":http://github.com/vatrai
\ No newline at end of file |