所以我听说轨道5上的红宝石已经出来了所以我决定升级我的rails版本。我无法弄清楚使用rails 5的方式:
# My current Ruby version
$ ruby -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-darwin15]
# My current Rails version
$ rails -v
Rails 4.2.6
当我运行gem install rails
时,它会安装最新版本的rails(5.0.0)
$ gem install rails
Password:
Successfully installed rails-5.0.0
Parsing documentation for rails-5.0.0
Done installing documentation for rails after 0 seconds
1 gem installed
现在如果我跑
$ gem list -l
*** LOCAL GEMS ***
actioncable (5.0.0, 5.0.0.beta2)
actionmailer (5.0.0, 5.0.0.beta2)
actionpack (5.0.0, 5.0.0.beta2)
actionview (5.0.0, 5.0.0.beta2)
activejob (5.0.0, 5.0.0.beta2)
activemodel (5.0.0, 5.0.0.beta2)
activerecord (5.0.0, 5.0.0.beta2)
activesupport (5.0.0, 5.0.0.beta2)
arel (7.1.1)
bigdecimal (default: 1.2.8)
builder (3.2.2)
bundler (1.12.5)
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
globalid (0.3.7)
i18n (0.7.0)
io-console (default: 0.4.5)
json (default: 1.8.3)
loofah (2.0.3)
mail (2.6.4)
method_source (0.8.2)
mime-types (3.1)
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.8.3)
net-telnet (0.1.1)
nio4r (1.2.1)
nokogiri (1.6.8)
pkg-config (1.1.7)
power_assert (0.2.6)
psych (default: 2.0.17)
rack (2.0.1)
rack-test (0.6.3)
rails (5.0.0, 5.0.0.beta2)
rails-deprecated_sanitizer (1.0.3)
rails-dom-testing (2.0.1, 1.0.7)
rails-html-sanitizer (1.0.3)
railties (5.0.0, 5.0.0.beta2)
rake (10.4.2)
rdoc (default: 4.2.1)
rubygems-update (2.6.6)
sprockets (3.7.0)
sprockets-rails (3.1.1)
test-unit (3.1.5)
thor (0.19.1)
thread_safe (0.3.5)
tzinfo (1.2.2)
websocket-driver (0.6.4)
websocket-extensions (0.1.2)
它显示我的rails版本现在是5.0.0。但如果我跑
$ rails -v
Rails 4.2.6
我还在使用rails 4.2.6。我该如何切换版本?
答案 0 :(得分:3)
尝试跑步:
$ rbenv rehash
当您安装包含可执行文件(例如rails)的新gem时,应该运行此命令。如果您通过Ryan Souza安装gem rbenv-rehash,它可以自动为您执行此操作。
答案 1 :(得分:1)
运行:
# To change your ruby version as global
$ rbenv global <ruby version>
$ rbenv rehash