How do I “force” my Rails 3 app to use 1.9.2

主宰稳场 提交于 2019-12-08 06:07:17

问题


I have setup Rails 3.0.3 and installed Ruby 1.9.2 with rvm and set rvm to use 1.9.2 by default.

However, when I create a new rails app and check the environmental variables it still reflects ruby 1.8.7, how do I update this to 1.9.2?


回答1:


You are probably executing an old 1.8.7 rails binary that is being found first in your UNIX search path.

You can type which rails at the command line to see which rails executable you are running. On my machine I get:

/Users/scott/.rvm/gems/ruby-1.9.2-p136/bin/rails

You can also check your binary search path by typing echo $PATH

If you get a result from which rails that looks something like:

/blah/blah/gems/ruby-1.8.7/bin/rails

... then you need to remove the old rails binary from your path, or use the old 1.8.7 ruby to uninstall the rails gems, so that they are not found and executed.

Once you have done this, the next time you try to execute rails s, the 1.9.2 version of the rails binary should be executed.




回答2:


With RVM, there is actually an easier way to set the default Ruby interpreter without modifying the path directly. Just run the following command

rvm --default use 1.9.2



回答3:


One of the best ways of handling this, particularly if you have to deal with rails 2 apps on the same system, is with RVM -- using it, you can can easily install multiple rubies (and sets of gems to go along with them), and switch between them with e.g. rvm use 1.9.2. You can even set it up to automatically switch to the right ruby when you cd into a project directory, described here.



来源:https://stackoverflow.com/questions/4553776/how-do-i-force-my-rails-3-app-to-use-1-9-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!