Rails 4: setting request.format does not update params[:format] -


in rails 3, params , request.parameters refer same object.

with addition of strong parameters in rails 4, params refers distinct instance of actioncontroller::parameters created request.parameters.

a side effect of once have called params (thereby creating distinct parameters object), calling request.format= not update params.

rails 3:

params # set @_params request.parameters request.format = "mobile" params[:format] => "mobile" 

rails 4:

params # set @_params parameters.new(request.parameters) request.format = "mobile" params[:format] => nil 

this isn't technically bug because it's easy enough client code request.format instead of params[:format] source of truth information (and not expect able use both interchangeably).

but feels design regression me. having params , request.parameters same "except exceptions" causing bug now, , expect cause bugs many devs in future.

am doing wrong? if so, why isn't issue , should doing differently? note use case brought me down path exact 1 docs format=.

this case because params hash intended business data application, whereas request.format represents http request response requests'. contents of params still same, have flexibility change request format without changing business data.

think of separation of concerns.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -