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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)