On Thursday, April 18, 2013 5:10:14 AM UTC+1, [email protected] wrote:
> Howdy,
>
>
>
> Is there any way I can just turn off this functionality? I think it might be
> because this is an EventsController, and Rails is trying to give me something
> for free, but I just want to send over whatever I want, especially as I will
> have situations like an OrdersController, that I want to pass an order to
> (such as id asc, etc..).
>
>
There are 2 things happening. First, by default if the content type is json
then rails assumes that the request body (in your case the empty string) is
json, and will parse it and add it to params.
The second is something called wrap_parameters.
This wraps the parameters from the body in a hash, so if you posted the document
{"name": "bob"}
To a users controller, instead of polluting the top level parameter namespace
it would set params[:user] to the result of parsing that.
There is an initializer that turns on wrap parameters. You could remove it
and/or only enable it for some controllers.
By default this only happens if the content type is json.
Lastly why are you setting the content type if you're not submitting the
request body (if you're trying to control the format of the response I find
that it's easiest not to mess around with headers and requests events.json
instead)
Fred
> Thanks for any help,
>
>
> Robert
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/UErCG079np8J.
For more options, visit https://groups.google.com/groups/opt_out.