每当我调用rails g model或rails s时,我都会遇到一个奇怪的错误。应用程序运行良好,现在我已经注意到我想添加一个新模型。
以下是运行rails g model my_model name:string
,rails c
和rails g controller test_controller
的堆栈跟踪:
/root/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:156:in `split': bad URI(is not URI?): (URI::InvalidURIError)
from /root/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:174:in `parse'
from /root/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/common.rb:628:in `parse'
from /root/my_project/config/initializers/redis.rb:1:in `<top (required)>'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `block in load'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
from /root/.rvm/gems/ruby-1.9.2-p290/bundler/gems/rails-dev-boost-60a39d477c26/lib/rails_development_boost/loadable_patch.rb:14:in `load'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/engine.rb:588:in `block (2 levels) in <class:Engine>'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/engine.rb:587:in `block in <class:Engine>'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /root/my_project/config/environment.rb:5:in `<top (required)>'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/application.rb:103:in `require'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
from /root/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.2.11/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
问题似乎与我正在使用的rails版本有关吗?我没有做任何改变,所以现在它失败了很奇怪。
感谢您的帮助。
更新
我正在使用3.2.13
和ruby 1.9.2p290
更新#2
在同一台机器上的其他项目上尝试这些命令,用户不会产生任何错误......
请帮忙! :(
答案 0 :(得分:0)
发现问题,开发中缺少一个ENV变量,由URI.parse解析,发送为nil,导致错误。