Ruby on rails 找不到编辑视图的路由

Ruby on rails 找不到编辑视图的路由,ruby-on-rails,ruby,ruby-on-rails-3.2,Ruby On Rails,Ruby,Ruby On Rails 3.2,我目前正试图查看我的一个网站资源的索引,但无论我尝试了什么,它都无法找到编辑路径。它一直给我: No route matches {:action=>"edit", :controller=>"posts", :user_id=>nil, :id=>nil} index.html.erb: <h1>Listing posts</h1> <table> <tr> <th>Postname</t

我目前正试图查看我的一个网站资源的索引,但无论我尝试了什么,它都无法找到编辑路径。它一直给我:

No route matches {:action=>"edit", :controller=>"posts", :user_id=>nil, :id=>nil}
index.html.erb:

<h1>Listing posts</h1>

<table>
  <tr>
    <th>Postname</th>
    <th>Postcontent</th>
    <th>Poster</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @posts.each do |post| %>
  <tr>
    <td><%= post.postname %></td>
    <td><%= post.postcontent %></td>
    <td><%= post.poster %></td>
    <td><%= link_to 'Show', user_posts_path %></td>
    <td><%= link_to 'Edit', edit_user_post_path(@user,@post) %></td>
    <td><%= link_to 'Destroy', user_posts_path, method: :delete, data: { confirm: 'Are you sure?' } %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New Post', new_user_post_path %>
rake路由输出:

    user_posts GET    /users/:user_id/posts(.:format)          posts#index
               POST   /users/:user_id/posts(.:format)          posts#create
 new_user_post GET    /users/:user_id/posts/new(.:format)      posts#new
edit_user_post GET    /users/:user_id/posts/:id/edit(.:format) posts#edit
     user_post GET    /users/:user_id/posts/:id(.:format)      posts#show
               PUT    /users/:user_id/posts/:id(.:format)      posts#update
               DELETE /users/:user_id/posts/:id(.:format)      posts#destroy
         users GET    /users(.:format)                         users#index
               POST   /users(.:format)                         users#create
      new_user GET    /users/new(.:format)                     users#new
     edit_user GET    /users/:id/edit(.:format)                users#edit
          user GET    /users/:id(.:format)                     users#show
               PUT    /users/:id(.:format)                     users#update
               DELETE /users/:id(.:format)                     users#destroy
          root        /                                        home#index

如果在路由路径上指定参数名称,则会发生什么情况,如下所示:

<td><%= link_to 'Edit', edit_user_post_path(:user_id => @user.id, :id => @post.id) %></td>
@user.id,:id=>@post.id)%>

很乐意帮忙。如果你能接受这个答案来帮助更多的用户,那就太好了。我计划,我不得不等待:)
    user_posts GET    /users/:user_id/posts(.:format)          posts#index
               POST   /users/:user_id/posts(.:format)          posts#create
 new_user_post GET    /users/:user_id/posts/new(.:format)      posts#new
edit_user_post GET    /users/:user_id/posts/:id/edit(.:format) posts#edit
     user_post GET    /users/:user_id/posts/:id(.:format)      posts#show
               PUT    /users/:user_id/posts/:id(.:format)      posts#update
               DELETE /users/:user_id/posts/:id(.:format)      posts#destroy
         users GET    /users(.:format)                         users#index
               POST   /users(.:format)                         users#create
      new_user GET    /users/new(.:format)                     users#new
     edit_user GET    /users/:id/edit(.:format)                users#edit
          user GET    /users/:id(.:format)                     users#show
               PUT    /users/:id(.:format)                     users#update
               DELETE /users/:id(.:format)                     users#destroy
          root        /                                        home#index
<td><%= link_to 'Edit', edit_user_post_path(:user_id => @user.id, :id => @post.id) %></td>