Routing Error: No route matches {:action=>"show", :controller=>"link_devices", :id=>nil}

Routing Error: No route matches {:action=>"show", :controller=>"link_devices", :id=>nil}

我收到这个错误,似乎 Link_device 'id 可以为空。但是我检查了数据库,我没有看到任何 link_device id is nil;

有什么建议吗?

<th>
    <%= dns_record_set.name %>
    <small>
        <% if dns_record_set.interface %>
            <%= link_to dns_record_set.interface.link_device, link_device_path(dns_record_set.interface.link_device) %>
        <% end %>
    </small>
</th>

如果 interface 存在,也为 link_device 添加条件。如下所示 -

<% if dns_record_set.interface && dns_record_set.interface.link_device %>