如何在我的Rails控制台中执行简单的`Date.today`

时间:2013-04-15 10:30:34

标签: ruby-on-rails ruby datetime irb

当我在rails命令中执行命令Date.today时,出现以下错误:

我无法在我的Rails控制台中执行简单的Date.today

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)> 

1 个答案:

答案 0 :(得分:0)

这里看起来RubyMine插件存在问题。当我在控制台中做同样的事情时,它可以工作。我不知道为什么这么简单的事情不适用于RubyMine。