Skip to content

Instantly share code, notes, and snippets.

@batter
Created December 29, 2011 15:55
Show Gist options
  • Save batter/1534696 to your computer and use it in GitHub Desktop.
Save batter/1534696 to your computer and use it in GitHub Desktop.
Demonstrating ActiveSupport's to_time method
(shell)
batkins: ~$: irb
1.8.7 :001> "12/10/11".to_time
NoMethodError: undefined method `to_time` for "12/10/11":String
from (irb):1
from :0
1.8.7 :002> # This demonstrates what you're talking about where it isn't finding the to_time method
1.8.7 :003> require 'rubygems'
=> true
1.8.7 :004> require 'active_support/all'
=> true
1.8.7 :005> "12/10/11".to_time
=> Thu, 10 Dec 0011 00:00:00 +0000
1.8.7 :006> "12/10/11".method(:to_time)
=> #<Method: String#to_time>
1.8.7 :007> "12/10/11".method(:to_time).__file__
=> "/Users/batkins/.rvm/gems/ree-1.8.7-2011.03@FB-cms/gems/activesupport-3.0.10/lib/active_support/core_ext/string/conversions.rb"
1.8.7 :008> "12/10/11".method(:to_time).__line__
=> 35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment