Bar*_*acs 2 ruby ruby-on-rails ruby-on-rails-3.2
所以我在顶部有一个Bootstrap导航栏.
我想link_to current_user的编辑路径,但我总是得到错误:
ActionController::RoutingError at /blog
No route matches {:action=>"edit", :controller=>"users"}
Run Code Online (Sandbox Code Playgroud)
这就是我现在正在尝试的:
<% if current_user %> <--! user logged in? -->
<% @user ||= current_user %>
<%= link_to 'Settings', edit_user_path %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
我在/ user/1 /页面上没有这个错误,但我在其他地方都有它.
也尝试了这个,但没有帮助:
def edit
if params[:id]
@user = User.find(params[:id])
else
@user = current_user
end
end
Run Code Online (Sandbox Code Playgroud)
试试这个,
<%= link_to 'Settings', edit_user_path(current_user) %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2251 次 |
| 最近记录: |