Normally rails magically decodes all params
. Now I got a javascript which does params="value="+encodeURIComponent('ab#cd');
and then calls http://server/controller?value=ab%23cd
. If I access params[:value]
in my controller, it contains ab%23cd
and not ab#cd
as I would expect.
How to solve this? Why does rails no auto decoding of this param?
Rails "automagically" handles parameters with the following logic.
If the request is GET it will decode anything in the query string:
If the request is a POST with a query string it will not decode it:
If the request is a POST with data parameters, it will decode it:
I suspect that you're seeing this issue because you're including a query string with a
POST
request instead of aGET
request and so Rails isn't decoding the query string.