Rails控制台不起作用(RuntimeError)

时间:2015-06-21 15:41:32

标签: ruby-on-rails-4

使用rails控制台的RuntimeError,rails服务器按预期工作。

我正在使用Mac OSX SL

ruby​​版本ruby 2.2.3p136 (2015-06-17 revision 50924) [i386-darwin10.0]

rails version Rails 4.2.2

如果我将bundle consolerequire_relative 'config/environment.rb'一起使用,则通常可以使用

/usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/application.rb:351:in `initialize!': Application has been already initialized. (RuntimeError)
from /users/mario/Sites/store4/config/environment.rb:5:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/application.rb:328:in `require_environment!'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:142:in `require_application_and_environment!'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:67:in `console'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-4.2.2/lib/rails/commands.rb:17:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
from /users/mario/Sites/store4/bin/rails:8:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `block in load'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
from /usr/local/lib/ruby/gems/2.2.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:268:in `load'
from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'

1 个答案:

答案 0 :(得分:0)

打开终端并移至项目目录并运行它。

rails console

或者如果您已经在项目中,则从那里运行相同的命令。

iMac-di-Mario:store4 mario$ pwd /Users/mario/Sites/store4 $ rails console