2016-10-07 47 views
3

很新的Rails的,所以和我一起承擔 -這個Rails控制檯錯誤信息有什麼問題嗎?

目前偏執地認爲我的紅寶石和寶石的版本是不是最新的,因爲運行時rails test我會偶爾出現錯誤消息。以前有rvm和rbenv都安裝,但我已經刪除了兩個,並重新安裝rvm只。

當我進入一個irb並調用不起作用的動作,如:"foo".select,我得到一個簡單的錯誤消息:

NoMethodError: private method 'select' called for "foo":String 
    from (irb):4 
    from /Users/Joseph/.rvm/rubies/ruby-2.3.1/bin/irb:11:in '<main>' 

然而,當我鍵入相同的命令"foo".selectrails console取而代之,我得到:

NoMethodError: private method `select' called for "foo":String 
    from (irb):1 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require' 
    from /Users/Joseph/workspace/sample_app/bin/rails:9:in `<top (required)>' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `run' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>' 
    from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from -e:1:in `<main>' 

這是正常的嗎?或者我的寶石有什麼問題嗎?

回答

2

你的寶石沒有問題。問題是,當你運行irb時,就是這樣。你只能運行ruby交互。 當你運行rails console爲了向你展示它需要使用的控制檯,並使用ActiveRecord,rails core等爲你設置它。所以這個(下面)是它設置之前的所有功能。

from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/console.rb:65:in `start' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/console_helper.rb:9:in `start' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:78:in `console' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/railties-5.0.0.1/lib/rails/commands.rb:18:in `<top (required)>' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `block in require' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require' 
    from /Users/Joseph/workspace/sample_app/bin/rails:9:in `<top (required)>' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `block in load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:259:in `load_dependency' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:287:in `load' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/commands/rails.rb:6:in `call' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/command_wrapper.rb:38:in `call' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:191:in `block in serve' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `fork' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:161:in `serve' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:131:in `block in run' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `loop' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application.rb:125:in `run' 
    from /Users/Joseph/.rvm/gems/[email protected]_app/gems/spring-1.7.2/lib/spring/application/boot.rb:19:in `<top (required)>' 
    from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from /Users/Joseph/.rvm/rubies/ruby-2.3.1/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' 
    from -e:1:in `<main>' 

注意IRB執行非常快,而軌控制檯需要它的時候,根據你的初始化,配置等

+0

感謝在清除了! – doctopus

+1

@JosephLiu我可以看到你永遠不會接受提供給你的問題的答案。當您提出問題時,其他用戶會盡力幫助您解決問題。你應該選擇最好的答案(如果確實對你有幫助),並接受它(在答案評分附近尋找複選標記)。這樣你就可以讓社區知道,你的問題已經解決,同時你也獎勵了幫助你的用戶。 –

+0

我完全同意你的看法@AndreyDeineko :) – JGutierrezC

相關問題