I am having a very strange problem, I have this file for User#show view:
%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)
and receive the error: undefined method 'category' for nil:NilClass
My model does have a category string attribute. What does this mean and how do I fix it?
It means that in this call:
applianceisnil. If it’s OK that not allappliance_profileshave anappliance, you can do this:If all the
appliance_profilesshould have anappliance, you have to check your database for missing data.