当我Date.today
在 rails 命令中执行命令时,出现以下错误:
我不能Date.today
在我的 Rails 控制台中做一个简单的事情
ruby-1.9.2-p180 :026 > >> require 'date'
=> false
ruby-1.9.2-p180 :027 > >> Date.today
ArgumentError: invalid date
from /Users/besi/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/date.rb:809:in `civil'
from /Users/besi/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/Date.rb:1810:in `today'
from (irb):27
from /Users/besi/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.2.11/lib/rails/commands/console.rb:47:in `start'
from /Users/besi/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.2.11/lib/rails/commands/console.rb:8:in `start'
from /Users/besi/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.2.11/lib/rails/commands.rb:41:in `<top (required)>'
from /Users/besi/Dropbox/projects/Freelance/vidis/VidiServer/script/rails:6:in `require'
from /Users/besi/Dropbox/projects/Freelance/vidis/VidiServer/script/rails:6:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
在 irb 控制台中,这可以正常工作:
ruby-1.9.2-p180 :001 > require 'date'
=> true
ruby-1.9.2-p180 :002 > Date.today
=> #<Date: 2013-04-15 (4912795/2,0,2299161)>