weird template error

Hi All,

I've been getting this weird template error for a while (I'm using Rails 1.0.0):

undefined method `title' for nil:NilClass On line #4 of app/views/discussion_mailer/notify.text.html.rhtml

4: <i>&nbsp; a new message has been posted to the <%= @discussion.title%> discussion</i> 5: <hr><br> 6:

I added a line to check if the discussion object is nil

undefined method `title' for nil:NilClass On line #4 of app/views/discussion_mailer/notify.text.html.rhtml

4: <%@discussion = @message.discussion if @discussion.nil?%> 5: <i>&nbsp; a new message has been posted to the <%= @discussion.title%> discussion</i> 6: <hr><br> 7:

but the error still occurs and the error says is it still happening on line 4, which is strange because the method "title" is no longer called on line 4.

Of course, you might say ah well @message.discussion is also nil, but the funny thing is that this error only occurs intermittently. It doesn't happen at all on my dev machine, only on the production machine, and then only occasionally. It's like the objects passed into the mailer just get dereferenced sometimes.

Anyway, I'm adding more logging to try and get extra info for when it happens again, but I thought I'd mail in case anyone has any ideas.

Many thanks in advance.