Issue with Observers and has_one association...

Hey Guys,

I'm getting a peculiar bug working with Observers and has_one associations. When a has_one association is invoked by an Observer it always returns null. I looked in the development.log file and the SQL for the has_one association isn't even being executed. On the other hand, when I replace the has_one association with just a hand crafted method, it does get called correctly. So the following does not work:

class Task

  has_one :current_instance,            :class_name => 'TaskInstance',            :foreign_key => 'task_id',            :order => 'start_at DESC',            :conditions => 'end_at IS NULL'

but when replaced with the follwoing, it does work.

  def current_instance     TaskInstance.find(:first,                       :conditions=>"task_id=#{self.id} AND end_at IS NULL",                       :order=>'start_at DESC'                      )   end

I'm working with Rails 2.0.2 and the problem doesn't affect the belongs_to nor the has_many associations. I'd hate to replace my lovely has_one associations with hand-crafted methods....

Sonny.