minor corrections

This commit is contained in:
Vijay Dev 2011-05-14 00:51:54 +05:30
parent 4ef4d57719
commit 159e605d19

@ -112,15 +112,15 @@ Note that the +params+ hash is actually an instance of +HashWithIndifferentAcces
h4. JSON/XML parameters
If you're writing a web service application, you might find yourself more comfortable on accepting parameters in JSON or XML format. Rails will automatically convert your parameters into +params+ hash, which you'll be able to access it like you would normally do with form data.
If you're writing a web service application, you might find yourself more comfortable on accepting parameters in JSON or XML format. Rails will automatically convert your parameters into +params+ hash, which you'll be able to access like you would normally do with form data.
So for example, if you sending this JSON parameter:
So for example, if you are sending this JSON parameter:
<pre>
{ "company": { "name": "acme", "address": "123 Carrot Street" }}
{ "company": { "name": "acme", "address": "123 Carrot Street" } }
</pre>
You'll get +params[:company]+ as +{ :name => "acme", "address" => "123 Carrot Street" }+.
You'll get <tt>params[:company]</tt> as <tt>{ :name => "acme", "address" => "123 Carrot Street" }</tt>.
Also, if you've turned on +config.wrap_parameters+ in your initializer or calling +wrap_parameters+ in your controller, you can safely omit the root element in the JSON/XML parameter. The parameters will be cloned and wrapped in the key according to your controller's name by default. So the above parameter can be written as:
@ -134,7 +134,7 @@ And assume that you're sending the data to +CompaniesController+, it would then
{ :name => "acme", :address => "123 Carrot Street", :company => { :name => "acme", :address => "123 Carrot Street" }}
</ruby>
You can customize the name of the key or specific parameters you want to wrap by consulting the "API documentation":http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html"
You can customize the name of the key or specific parameters you want to wrap by consulting the "API documentation":http://api.rubyonrails.org/classes/ActionController/ParamsWrapper.html
h4. Routing Parameters