Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails嵌套资源错误_Ruby On Rails - Fatal编程技术网

Ruby on rails Rails嵌套资源错误

Ruby on rails Rails嵌套资源错误,ruby-on-rails,Ruby On Rails,我有这个嵌套资源 resources :products do resources :senders end 在我的产品/索引视图中,我有以下内容 ... .. . <td><%= link_to 'Show Email Addresses', product_senders_path(product) %> </td> . .. ... 。。。 .. . . .. ... 这似乎是工作,它重定向到该产品的发件人我。现在出于某种奇怪的

我有这个嵌套资源

  resources :products do
     resources :senders
  end 
在我的产品/索引视图中,我有以下内容

...
..
.
<td><%= link_to 'Show Email Addresses', product_senders_path(product) %> </td>
.
..
...
。。。
..
.
.
..
...
这似乎是工作,它重定向到该产品的发件人我。现在出于某种奇怪的原因,我得到了这个:

 NameError in Senders#index

undefined local variable or method `sender_path' for #<#<Class:0x00000003cb1f58>:0x00000003b46e48>

Extracted source (around line #18):

15:     <td><%= sender.product_id %></td>
16:     <td><%= sender.name %></td>
17:     <td><%= sender.email %></td>
18:     <td><%= link_to 'Show', sender %></td>
19:     <td><%= link_to 'Edit', edit_sender_path(sender) %></td>
20:     <td><%= link_to 'Destroy', sender, confirm: 'Are you sure?', method: :delete %></td>
21:   </tr>
发件人#索引中的
name错误
未定义的局部变量或方法“sender\u path”#
提取的源(第18行附近):
15:     
16:     
17:     
18:     
19:     
20:     
21:   
这是我的发件人/索引文件:

<h1>Listing senders</h1>

<table>
  <tr>
    <th>Application</th>
    <th>Name</th>
    <th>Email</th>
    <th></th>
    <th></th>
    <th></th>
  </tr>

<% @senders.each do |sender| %>
  <tr>
    <td><%= sender.product_id %></td>
    <td><%= sender.name %></td>
    <td><%= sender.email %></td>
    <td><%= link_to 'Show', sender %></td>
    <td><%= link_to 'Edit', edit_sender_path(sender) %></td>
    <td><%= link_to 'Destroy', sender, confirm: 'Are you sure?', method: :delete %></td>
  </tr>
<% end %>
</table>

<br />
列出发件人
应用
名称
电子邮件


为什么我会犯这个错误?在它正常工作之前

因为只有发件人的嵌套路由,所以没有
编辑发件人路径(发件人)
帮助程序,只有
编辑产品发件人路径(产品,发件人)


通过执行
rake routes

您可能会看到所有应用程序路由帮助程序的列表。嘿,谢谢,现在它似乎可以工作了,但问题是,每次我尝试创建发送方时,发送方都会被创建,我只会得到一个路由错误!有什么想法吗?谢谢