生产中无法启动rails控制台:无效选项-e

时间:2014-01-07 03:42:42

标签: ruby-on-rails ruby-on-rails-3 console rails-console

出于某种原因,我们无法在生产中运行rails console。命令rails console -e production适用于我们的Windows计算机,但在我们的Mac上失败。

This SO post解释了如何解决它,但有人可以解释为什么我们在一台机器上看到这条错误消息而不是另一台机器上的错误消息吗?

/usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:23:in `block in start': invalid option: -e (OptionParser::InvalidOption)
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:18:in `new'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:18:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands/console.rb:8:in `start'
    from /usr/local/rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.12/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

谢谢!

2 个答案:

答案 0 :(得分:2)

与错误一样,-e不是rails控制台命令的有效选项(在您的Rails版本中)。这是正确的用法:

$ rails console --help
Usage: console [environment] [options]
    -s, --sandbox                    Rollback database modifications on exit.
        --debugger                   Enable ruby-debugging for the console.
        --irb                        DEPRECATED: Invoke `/your/choice/of/ruby script/rails console` instead

答案 1 :(得分:0)

实际上,我确实看到了-e选项。有趣的

rails console --help

给出

Usage: rails console [environment] [options]
    -s, --sandbox                    Rollback database modifications on exit.
    -e, --environment=name           Specifies the environment to run this console under (test/development/production).
                                     Default: development
        --debugger                   Enable the debugger.

rails console -e production

给了我

Loading production environment (Rails 4.0.1)
irb(main):001:0>

我在Rails 4.0.1上。

编辑 - 错过了有关3.2.12中问题的部分。