2015-06-21 116 views
0

RuntimeError與Rails控制檯,Rails服務器按預期工作。Rails控制檯無效(RuntimeError)

我使用的是Mac OSX SL

紅寶石版ruby 2.2.3p136 (2015-06-17 revision 50924) [i386-darwin10.0]

軌版本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>' 

回答

0

打開終端轉到您的項目目錄並運行它。

rails console 

或者如果您已經在您的項目中,則從那裏運行相同的命令。

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

我已經在項目目錄'的iMac二馬里奧:store4馬里奧$ PWD /用戶/馬里奧/網站/ store4' – user3832640

+0

然後請執行上面的命令。什麼是捆綁控制檯?請運行rails console而不是捆綁控制檯。 – Packer

+0

'rails console'不起作用 – user3832640