简体   繁体   English

未初始化的常量RAILS_ROOT:Surveyor gem和使用Rails.root

[英]Uninitialized constant RAILS_ROOT: Surveyor gem and using Rails.root

I'm trying to set up the surveyor gem using the installation guide provided. 我正在尝试使用提供的安装指南来设置Surveyor gem I am working from the surveyor-example that is available here , so I assumed I would be working from older code. 我正在从这里可用的测量师示例工作,因此我假设我将在较旧的代码中工作。 However, when I run 但是,当我跑步时

bundle exec rake surveyor FILE=surveys/kitchen_sink_survey.rb

It comes up with the error "uninitialized constant RAILS_ROOT". 出现错误“未初始化的常量RAILS_ROOT”。 I read here that a solution to this is to try using Rails.root , but I'm not sure where to change this setting. 在这里读到解决方案是尝试使用Rails.root ,但是我不确定在哪里更改此设置。 Is this something I set in environment.rb or within the survey code itself? 这是我在environment.rb或调查代码本身中设置的吗?

If it provides any futher help, here's the result of the trace: 如果它提供任何进一步的帮助,则是跟踪的结果:

/home/nitrous/surveyor_example/.bundle/bundler/gems/surveyor-a95169e36afc/lib/tasks/surveyor_tasks.rake:7:in `block (2 levels) in <top (required)>'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:174:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/usr/local/opt/rbenv/versions/2.1.5/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/home/nitrous/surveyor_example/.bundle/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/home/nitrous/surveyor_example/.bundle/bin/rake:23:in `load'
/home/nitrous/surveyor_example/.bundle/bin/rake:23:in `<main>'

The error is coming from the version of the surveyor gem you are using. 该错误来自您所使用的Surveyor gem的版本。 surveyor-a95169e36afc refers to an older version. surveyor-a95169e36afc是指较旧的版本。

In your Gemfile make sure you just have 在您的Gemfile中,确保您只有

gem 'surveyor'

and bundle install bundle install

once that is set , it should install surveyor 0.20.0 which will work with your version of rails. 一旦设置好,它应该安装surveyor 0.20.0 ,它将与您的Rails版本一起使用。

The Gemfile included in the tutorial is out of date/for a different version of rails. 本教程中包含的Gemfile已过期/用于其他版本的rails。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM