我有一个非常奇怪的问题,我有这个文件用于 User#show 视图:
%h1 My Appliances
.floatright= link_to "Add appliance", new_appliance_profile_path
%table
%tr
%th Category
%th Manufacturer
%th Model
%th Room
%th Hours On
%th Hours Sleeping
%th
- @user.appliance_profiles.each do |ap|
%tr{:class => cycle('list_line_odd', 'list_line_even')}
%td= ap.appliance.category
%td= ap.appliance.manufacturer
%td= ap.appliance.model
%td= ap.room.name
%td= ap.hours_on
%td= ap.hours_sleep
%td= link_to "edit", edit_appliance_profile_path(ap)
并收到错误:undefined method 'category' for nil:NilClass
我的模型确实有一个类别字符串属性。这是什么意思,我该如何解决?