Forum: Ruby on Rails Trouble with Date class

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
43b250d41a583ea8a93dc198b06862b3?d=identicon&s=25 gruner.rails (Guest)
on 2005-12-05 01:44
(Received via mailing list)
I'm having trouble with Ruby's Date class. I'm trying to do something
as simple as "Date.today" but I keep getting errors.

I've included "require 'date'" to environment.rb but still no luck.

Am I doing something wrong?

Thanks,
-Andrew
3203ed0e608d3bfae1e31282e629ffa2?d=identicon&s=25 peter.fitzgibbons (Guest)
on 2005-12-05 17:12
(Received via mailing list)
What's your Ruby version ?
C:\ruby\dev\buildview>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]

What's the error ?
C:\ruby\dev\buildview>irb
irb(main):001:0> Date.today
NameError: uninitialized constant Date
        from (irb):1
irb(main):002:0> require 'date'
=> true
irb(main):003:0> Date.today
=> #<Date: 4907419/2,0,2299161>

On 12/4/05, Andrew Gruner <gruner.rails@gmail.com> wrote:
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>



--
43b250d41a583ea8a93dc198b06862b3?d=identicon&s=25 gruner.rails (Guest)
on 2005-12-05 19:24
(Received via mailing list)
Ruby version: ruby 1.8.2 (2004-12-25) [powerpc-darwin7.8.0]

I was able to duplicate what you showed in irb:
irb(main):001:0> Date.today
NameError: uninitialized constant Date
        from (irb):1
irb(main):002:0> require 'date'
=> true
irb(main):003:0> Date.today
=> #<Date: 4907419/2,0,2299161>
irb(main):004:0>

But when I try running my rails app I get the error: "undefined method
`today' for #<Date: -1/2,0,2299161>"

-Andrew
3203ed0e608d3bfae1e31282e629ffa2?d=identicon&s=25 peter.fitzgibbons (Guest)
on 2005-12-05 19:40
(Received via mailing list)
On 12/5/05, Andrew Gruner <gruner.rails@gmail.com> wrote:
> => #<Date: 4907419/2,0,2299161>
>
Show your code and error/trace for more help.
--
This topic is locked and can not be replied to.