I am trying to write a simple script for my Rails 2.3 application, but I am encountering a problem.
When I start rails console
and type Time.now - 1.month
it gives the correct output:
>> Time.now - 1.month
=> Mon Dec 07 17:05:50 +0100 2015
When I use the same piece of code inside a file (script/foo.rb) then I get the error
undefined method 'month' for 1:Fixnum (NoMethodError)
I am also not able to require
files from the "lib" directory. In Rails 2.3 the "lib" directory is already inside $LOAD_PATH
. This problem has given me a headache. Hopefully someone can help me.
Here are details about my system:
$ which -a ruby
/usr/bin/ruby
/Users/rakesh/.rvm/rubies/ruby-1.8.7-p374/bin/ruby
The same script works fine on my friend's machine so I am guessing that something is wrong in my computer.