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.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---