Date magic?

Hi.

When I read Dave and Davids excellent book “Agile Web D. with
Rails” the first time, I was particularly impressed with the following
statement:
1.day.from_now

It was used in a test class to set the date of tomorrow dynamically.
Since
it was enclosed in in ERb tags, I assumed this was a normal ruby
statement,
but when I tried it in my irb, i get the following error:
irb(main):007:0> 1.day.from_now
NoMethodError: undefined method `day’ for 1:Fixnum
from (irb):7
irb(main):008:0>

I would be abliged if someone could explain to me how this works in ERb
and
not in standard ruby? Have I missed something fundamental here?

Best regards,
Jørn �lmheim
www: http://www.olmheim.com
blog: http://blog.olmheim.com

Its an extension f the Time class

http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/Numeric/
Time.html

So, its not ruby, its rails…

On Friday, March 31, 2006, at 1:48 PM, Jørn Ølmheim wrote:

irb(main):007:0> 1.day.from_now
blog: http://blog.olmheim.com


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Mikkel B.

www.strongside.dk - Football Portal(DK)
ting.minline.dk - Buy Old Stuff!(DK)

Indeed. You need to use script/console instead of a plain ruby shell.

On 31 Mar 2006 12:02:10 -0000, Mikkel B. <

On 31-mrt-2006, at 13:48, Jørn Ølmheim wrote:

the following error:
irb(main):007:0> 1.day.from_now
NoMethodError: undefined method `day’ for 1:Fixnum
from (irb):7
irb(main):008:0>

I would be abliged if someone could explain to me how this works in
ERb and not in standard ruby? Have I missed something fundamental
here?

days_from_now etc. is a part of ActiveSupport

Heh, in a thread last week about Rails driving development of Ruby,
somebody asked how long it would be til someone mistook Rails’
core-extensions for Ruby :slight_smile:

Jeff

Julian ‘Julik’ Tarkhanov wrote:

On 31-mrt-2006, at 13:48, J�rn �lmheim wrote:

the following error:
irb(main):007:0> 1.day.from_now
NoMethodError: undefined method `day’ for 1:Fixnum
from (irb):7
irb(main):008:0>

I would be abliged if someone could explain to me how this works in
ERb and not in standard ruby? Have I missed something fundamental
here?

days_from_now etc. is a part of ActiveSupport