@@ -132,7 +132,7 @@ response:
132132``` ruby
133133# Expects a response of
134134#
135- # {"id":1,"first ":"Tyler","last ":"Durden"}
135+ # {"id":1,"first_name ":"Tyler","last_name ":"Durden"}
136136#
137137# for GET http://api.people.com:3000/people/1.json
138138#
@@ -144,14 +144,14 @@ JSON element becoming an attribute on the object.
144144
145145``` ruby
146146tyler.is_a? Person # => true
147- tyler.last # => 'Durden'
147+ tyler.last_name # => 'Durden'
148148```
149149
150150Any complex element (one that contains other elements) becomes its own object:
151151
152152``` ruby
153153# With this response:
154- # {"id":1,"first ":"Tyler","address":{"street":"Paper St.","state":"CA"}}
154+ # {"id":1,"first_name ":"Tyler","address":{"street":"Paper St.","state":"CA"}}
155155#
156156# for GET http://api.people.com:3000/people/1.json
157157#
@@ -166,15 +166,30 @@ Collections can also be requested in a similar fashion
166166# Expects a response of
167167#
168168# [
169- # {"id":1,"first ":"Tyler","last ":"Durden"},
170- # {"id":2,"first ":"Tony","last ":"Stark",}
169+ # {"id":1,"first_name ":"Tyler","last_name ":"Durden"},
170+ # {"id":2,"first_name ":"Tony","last_name ":"Stark",}
171171# ]
172172#
173173# for GET http://api.people.com:3000/people.json
174174#
175175people = Person .all
176- people.first # => <Person::xxx 'first' => 'Tyler' ...>
177- people.last # => <Person::xxx 'first' => 'Tony' ...>
176+ people.first # => <Person::xxx 'first_name' => 'Tyler' ...>
177+ people.last # => <Person::xxx 'first_name' => 'Tony' ...>
178+ ```
179+
180+ Collections can be filtered with query parameters
181+
182+ ``` ruby
183+ # Expects a response of
184+ #
185+ # [
186+ # {"id":1,"first_name":"Tyler","last_name":"Durden"},
187+ # ]
188+ #
189+ # for GET http://api.people.com:3000/people.json?last_name=Durden
190+ #
191+ people = Person .where(last_name: " Durden" )
192+ people.first # => <Person::xxx 'first_name' => 'Tyler' ...>
178193```
179194
180195### Create
@@ -185,12 +200,12 @@ id of the newly created resource is parsed out of the Location response header a
185200as the id of the ARes object.
186201
187202``` ruby
188- # {"first ":"Tyler","last ":"Durden"}
203+ # {"first_name ":"Tyler","last_name ":"Durden"}
189204#
190205# is submitted as the body on
191206#
192- # if include_root_in_json is not set or set to false => {"first ":"Tyler"}
193- # if include_root_in_json is set to true => {"person":{"first ":"Tyler"}}
207+ # if include_root_in_json is not set or set to false => {"first_name ":"Tyler"}
208+ # if include_root_in_json is set to true => {"person":{"first_name ":"Tyler"}}
194209#
195210# POST http://api.people.com:3000/people.json
196211#
@@ -199,7 +214,7 @@ as the id of the ARes object.
199214#
200215# Response (201): Location: http://api.people.com:3000/people/2
201216#
202- tyler = Person .new (:first => ' Tyler' )
217+ tyler = Person .new (:first_name => ' Tyler' )
203218tyler.new? # => true
204219tyler.save # => true
205220tyler.new? # => false
@@ -213,21 +228,21 @@ with the exception that no response headers are needed -- just an empty response
213228server side was successful.
214229
215230``` ruby
216- # {"first ":"Tyler"}
231+ # {"first_name ":"Tyler"}
217232#
218233# is submitted as the body on
219234#
220- # if include_root_in_json is not set or set to false => {"first ":"Tyler"}
221- # if include_root_in_json is set to true => {"person":{"first ":"Tyler"}}
235+ # if include_root_in_json is not set or set to false => {"first_name ":"Tyler"}
236+ # if include_root_in_json is set to true => {"person":{"first_name ":"Tyler"}}
222237#
223238# PUT http://api.people.com:3000/people/1.json
224239#
225240# when save is called on an existing Person object. An empty response is
226241# is expected with code (204)
227242#
228243tyler = Person .find(1 )
229- tyler.first # => 'Tyler'
230- tyler.first = ' Tyson'
244+ tyler.first_name # => 'Tyler'
245+ tyler.first_name = ' Tyson'
231246tyler.save # => true
232247```
233248
0 commit comments