class Task < ActiveRecord::Base
belongs_to :court
has_many :workflow_tasks
has_many :task_users, :dependent => :destroy
has_many :court_users, :through => :task_users
end
class TaskUser < ActiveRecord::Base
belongs_to :task
belongs_to :court_user
end
I accessed the court_user as follows:
task.task_users.collect{|task_user|task_user.court_user.user.name}
Error:
undefined method `court_user’ for #TaskUser:0x60f4320
Anyone knows the solution. It only happens in the development mode. It
seams the autoloading not working properly.
If I find the TaskUser directly like following it will work, but this is
not the right solution.
task_users = TaskUser.find(:all, :conditions=>[‘task_id=?’,task.id])
task_users.collect{|task_user|task_user.court_user.user.name}