overwrite_params deprecated as of Rails 2.3.6 -- Accepted Workaround?
So, it looks like overwrite_params
is deprecated as of Rails 2.3.6. Is there a suitable workaround that is generally accepted as bes开发者_运维百科t-practice?
For example, I used to to be able to do the following (which I thought was quite useful):
url_for(:overwrite_params => {:page => 1})
I've seen the following solution mentioned online ... is this the new way to do it?
url_for(request.params.merge(:page => 1))
Thanks for the help.
I actually just saw this mentioned in a Railscast episode: http://railscasts.com/episodes/240-search-sort-paginate-with-ajax
He suggests basically what you said, using params.merge. Note that you don't need to say request.params, params is sufficient. Also if you're using link_to, then you may not need url_for. In other words, if you have:
link_to title, url_for(params.merge(:page => 1))
then it might suffice to say
link_to title, params.merge(:page => 1)
精彩评论