【发布时间】:2016-05-08 10:11:35
【问题描述】:
尝试编辑用户个人资料:
在_footer (link_to "Edit profile", edit_user_path):
<% if current_user %>
<% if admin? %>
<%= link_to "Admin Page", admin_users_path %> Signed in as <%= current_user.username %> <%= link_to "Edit profile", edit_user_path %>(<%= link_to "Log out", session_path("current"), method: :delete %>) etc
在用户控制器中:
def edit
@user = current_user
end
在用户编辑视图中:
<%= form_for @user do |f| %>
<% if @user.errors.any? %>
etc
路线:
resources :users, only: [:new, :create, :edit]
我显然遗漏了一些关键概念,完全指向另一个控制器:ActionController::UrlGenerationError in Movies#index,
没有路由匹配 {:action=>"edit", :controller=>"users"} 缺少必需的键:[:id]
只是想知道这是怎么回事,谢谢!
【问题讨论】:
-
找到了一个很好的教程。
标签: ruby-on-rails path