0

我有以下内容projects_controller

def edit
  @project = Project.find(params[:id])
  @project.current_step = @project.first_step
  @user = current_user
end

我的以下路线routes.rb

resources :users do
 resources :projects
end

在我的views/users/show.html.erb我有:

<%= link_to image_tag('img_blank.png'), edit_user_project_path, :class => "btn_edit_project" %>

rake routes给我:

...
  edit_user_project GET    /users/:user_id/projects/:id/edit(.:format)      projects#edit
...

我仍然收到错误:

`Routing Error: No route matches {:action=>"edit", :controller=>"projects"}`

我对此束手无策。有什么帮助吗?

4

1 回答 1

2

edit_user_project_path期望参数:你@user和你的@project

<%= link_to image_tag('img_blank.png'), edit_user_project_path(@user, @project), :class => "btn_edit_project" %>
于 2013-02-11T21:36:00.873 回答