【发布时间】:2019-09-19 08:24:47
【问题描述】:
routes.rb
resources :customers do
resources :orders
end
resources :orders, :only => [:index]
我有意分隔订单索引以列出所有客户的所有订单。
我能够通过以下方式访问父对象的特定字段(我相信我必须将此计算放在帮助程序中):
<%= Customer.find(order.customer_id).clinic_name %>
但不知道如何指定customer_path 的正确路径,以便将其带到其父对象的显示页面。
现在,我在下面标记为 _what_to_put_here_,我正在努力弄清楚?
<% @orders.each do |order| %>
<tr>
<td><%= order.doctor_name %></td>
<td><%= order.patient_name %></td>
<td><%= link_to <%= Customer.find(order.customer_id).clinic_name,
customer_path(_what_to_put_here_) %></td>
<td><%= order.note %></td>
</tr>
<% end %>
【问题讨论】:
标签: ruby routes nested relational-database ruby-on-rails-6