I'm working on upgrading rails 3.2 app to rails 4.2. I have stuck with one issue. link_to with controller and action name not working
<%= link_to "Login", :controller => "user", :action => "login" %>
This is the link I want to convert into rails 4 code. using the same fashion.
I have tried this way.
<%= link_to "Login", { controller: "user", action: "login" } %>
its gives be below error:
ArgumentError: wrong number of arguments (given 2, expected 0..1)
Is anyone faced this issue. I have google this but not solved this.
Try with the controller
and action
as options, not within a hash:
<%= link_to 'Login', controller: 'user', action: 'login' %>
Or also you can check the specific route for Users#login and pass it as the second option.
I was looking at the documentation https://apidock.com/rails/v4.0.2/ActionView/Helpers/UrlHelper/link_to
<%= link_to "Profile", controller: "profiles", action: "show", id: @profile %>
# => <a href="/profiles/show/1">Profile</a>
you should be able to do
<%= link_to "Login", controller: "user", action: "login" %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.