comparing datetime

Hi all,

I have an event containing a datetime and want to see if that datetime is in the past.

I have a method in event   def future_event?     if self.start <= DateTime.now()       return true     end     false   end

on an event I can the do event.future_event?

This results in You have a nil object when you didn't expect it! The error occurred while evaluating nil.<=

The strange thing is that self is definatly not nil? Is this a problem with DateTime.now()?

regards, Stijn

This results in You have a nil object when you didn't expect it! The error occurred while evaluating nil.<=

It's not telling you that self is nil (which as you point out it isn't usually), it's telling you that self.start is nil.

Fred

self.start indeed returns a nil value but the strange this is that it is when I look at the self.attributes -> start in the debugger it is correctly filled in. Is start a name you can't use in rails?

Regards, Stijn

self.start indeed returns a nil value but the strange this is that it is when I look at the self.attributes -> start in the debugger it is correctly filled in. Is start a name you can't use in rails?

Oh, you may be running into an edge case when running under the
debugger. Old versions of rdebug would define their own start method.

Fred

I changed the name of 'start' to 'begin' and it works now in debug.

Thanks Stijn