I have the following models
1. class Caregiver < ActiveRecord::Base 2. has_many :call_orders 3. has_many :users, :through => :call_orders 4. end 5. 6. class User < ActiveRecord::Base 7. has_many :call_orders, :order => :position 8. has_many :caregivers, :through => :call_orders 9. end 10. 11. class CallOrder < ActiveRecord::Base 12. belongs_to :user 13. belongs_to :caregiver 14. acts_as_list :scope => :user 15. end
When I run the following commands, I get an error:
1. @call_list = User.find(params[:id]) 2. @call_list.call_orders.each do |call_order| 3. puts call_order.caregiver.first_name
This is the error:
You have a nil object when you didn't expect it! The error occurred while evaluating nil.first_name