views:

107

answers:

1

With overwrite_params, I was doing this to prepare a PDF request for a page:

 url_for(:overwrite_params => {:format => :pdf}) 

overwrite_params has been deprecated after Rails 2.3.8, is there a reason for this deprecation? What's the standard accepted alternative?

A: 

I am guessing they deprecated the method to simplify it, so you just have to pass in the parameters you want to overwrite, instead of writing :overwrite_params. It makes sense that this method should overwrite the parameters by default.. if you are specifying parameters you obviously want to use the specified values instead of the existing.

You should be able to do it like this instead:

url_for(:format => :pdf) 

A quick test on my users index page returns this:

/users.pdf
cowboycoded
This will not include the current params, the alternative seems to be doing something like: url_for(params.merge :format => :pdf), but I can't find a reason why the overwrite option has been deprecated
Samer Abukhait
I see what you mean about the existing params being ignored. It does not appear that a reason for this deprecation was given in Lighthouse or the rails commit comments.
cowboycoded