Posted over 8 years ago. Visible to the public.

Alternative to url_for's deprecated :overwrite_params option

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

Copy
DEPRECATION WARNING: The :overwrite_params option is deprecated. Specify all the necessary parameters instead.

that is for example caused by

Copy
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:

Copy
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.

Once an application no longer requires constant development, it needs periodic maintenance for stable and secure operation. makandra offers monthly maintenance contracts that let you focus on your business while we make sure the lights stay on.

Owner of this card:

Avatar
Ulrich Berkmueller
Last edit:
over 2 years ago
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Ulrich Berkmueller to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more