Rails 4 upgrade gotcha #1 (routes definition)
When I upgraded from Rails 3 to 4, I ran into some problems which I will share here.
If you use Sorcery or Authlogic for authorization, you create your login and logout routes by yourself. I found this code in my routes.rb file, where the
/login path is used for
POST requests and can be refered to as
While this works well with Rails 3, you get the following error with Rails 4:
How to fix this? Just use
post instead of
match to describe the routes and remove the
This looks shorter and nicer, plus both routes are still available as
login_path. So far so good, but how does this work with routes containing variables? Like here:
The solution: just use
post like above. To make it available as a named route, you have to set the
as option for the first route. The second will be automatically available under the same name.