ruby on rails - Why do none of the instance methods work on DateTime object? -


require 'date' = datetime.now sunday = - now.wday  >> sunday = - now.wday => #<datetime: 53058180361250947/21600000000,-5/24,2299161> 

since sunday datetime object, should able call instance methods such to_date or midnight, both of listed in rails documentation.

however, get

>> sunday.to_time nomethoderror: undefined method `to_time' #<datetime: 53058180361250947/21600000000,-5/24,2299161>         (irb):17 

actually none of these instance methods work on it. i'm using irb mode, , not know what's going on. can 1 tell me how fix problem?

they're not ruby methods, they're rails methods, in active support. and, in irb, active support not loaded default.

http://api.rubyonrails.org/classes/datetime.html#method-i-to_time


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -