ruby - rails项目中使用配置文件来确定rails版本如何实现版本切换的
阿神
阿神 2017-04-22 08:58:48
0
2
685

最近在折腾这个开源项目canvas-lms

按照他wiki中的步骤配置完环境之后,跑起来,发现竟然是rails2.3.18我了个去

然后仔细看了他的Gemfile,发现了一个canvas_rails3的配置文件

# You can enable the not-yet-complete Rails3 support by either defining a
# CANVAS_RAILS3 env var, or create an empty RAILS3 file in the canvas config dir
if ENV['CANVAS_RAILS3']
  CANVAS_RAILS3 = ENV['CANVAS_RAILS3'] != '0'
else
  CANVAS_RAILS3 = File.exist?(File.expand_path("../RAILS3", __FILE__))
end
CANVAS_RAILS2 = !CANVAS_RAILS3

发现是通过ENV['CANVAS_RAILS3']来控制rails版本是2还是3的,想请问下这个ENV['CANVAS_RAILS3']这个环境变量值应该如何修改或者赋值呢,是从命令行传入么,看了rubydoc发现没怎么明白

阿神
阿神

闭关修行中......

reply all(2)
巴扎黑

There is a big gap between rails 3.2 and current rails 4. Upgrading rails may cause the website to not run. Therefore, it is recommended to specify the same version as the project in the gemfile, and then bundle install

Peter_Zhu
  • If you follow section Quick Start, execute

    CANVAS_RAILS3=1 $GEM_HOME/bin/bundle exec script/server
    

    Alternative

    $GEM_HOME/bin/bundle exec script/server
    
  • If you follow Production Start 小节来做的话,你是不是之前创建了一个 canvasuser 用户?你可以在这个用户的 ~/.bashrc, add this sentence:

    export CANVAS_RAILS3=1
    

    Then when you start canvas, you should be using Rails3

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template