I have the following models
- class Caregiver < ActiveRecord::Base
- has_many :call_orders
- has_many :users, :through => :call_orders
- end
- class User < ActiveRecord::Base
- has_many :call_orders, :order => :position
- has_many :caregivers, :through => :call_orders
- end
- class CallOrder < ActiveRecord::Base
- belongs_to :user
- belongs_to :caregiver
- acts_as_list :scope => :user
- end
When I run the following commands, I get an error:
- @call_list = User.find(params[:id])
- @call_list.call_orders.each do |call_order|
- 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