Ruby on rails 使用designe链接到嵌套资源的rails

Ruby on rails 使用designe链接到嵌套资源的rails,ruby-on-rails,devise,nested-resources,Ruby On Rails,Devise,Nested Resources,Action::Controller表示link_to方法中profile id的值为nil。这是我的代码: <p id="notice"><%= notice %></p> <h2>Listing Schools</h2> <table> <thead> <tr> <th colspan="3"></th> </tr> <

Action::Controller表示link_to方法中profile id的值为nil。这是我的代码:

<p id="notice"><%= notice %></p>
<h2>Listing Schools</h2>
<table>
  <thead>
    <tr>
      <th colspan="3"></th>
    </tr>
  </thead>
  <tbody>
    <% @schools.each do |school| %>
      <tr>
        <td><%= school.name %></td>
        <td><%= link_to edit_user_profile_school_path(current_user, school) %>
      </tr>
    <% end %>
  </tbody>
</table>
<br>
<%= link_to 'New School', new_school_path %>

列出学校名单

您需要为参数指定密钥:

<%= link_to edit_user_profile_school_path(profile_id: current_user.id, school_id: school.id) %>

在没有看到更多代码的情况下很难确定,但看起来您缺少了:您的参数中的profile_id

我必须如此明确吗?这是路线编辑_user_profile_school GET/users/:user_id/profile/schools/:id/edit(:format)schools#edit这是我的应用程序的另一个链接,但这个链接有效你看到我使用当前用户对象而不是当前用户id的方式了吗?这就行了…你还把配置文件id和用户id“profile\u id:current\u user.id,”
post 'users/:profile_id/schools/:school_id'