Read more

Alternative to url_for's deprecated :overwrite_params option

Ulrich Berkmueller
March 15, 2011Software engineer

If you have the following deprecation warning after upgrading to rails >= 2.3.10

DEPRECATION WARNING: The :overwrite_params option is deprecated. Specify all the necessary parameters instead.
Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

that is for example caused by

url_for( :overwrite_params => { :order => 'name', :dir => 'asc' } )

you can fix this by using params.merge {:my_param_to_overwrite => 'foo' }.
To fix the example above the code could look like:

url_for( params.merge { :order => 'name', :dir => 'asc' } )

Note:

link_to uses url_for internally, so you can can use params.merge { ... } as the second parameter of link_to.

Posted by Ulrich Berkmueller to makandra dev (2011-03-15 08:37)