简体   繁体   English

更改Ruby on Rails的版本

[英]Change version of Ruby on Rails

I'm trying to install a CMS that requires Ruby on Rails 3.2.x, which I presume means any version of Ruby on Rails that supersedes 3.2.0. 我正在尝试安装一个需要Ruby on Rails 3.2.x的CMS,我认为这是指取代3.2.0的任何版本的Ruby on Rails。

So I installed Rails version 3.2.8, but I can't use it. 因此,我安装了Rails 3.2.8版,但无法使用。

Could someone explain what's going on here? 有人可以解释这是怎么回事吗? Also, if a project requires 3.2.x does that mean I include it in the project's gemfile, or do I have to install it as I'm trying to do here? 另外,如果一个项目需要3.2.x,这是否意味着我将其包含在项目的gemfile中,还是在这里尝试安装时必须安装它?

Ruby on Rails终端截图

To specify the version of rails you want to use, in your gemfile: 要在gemfile中指定要使用的rails版本:

gem 'rails', 'version'

Change version to the version you want then run $ bundle install 更改version到你想要,那么该版本运行$ bundle install

RVM is the Ruby Version Manager, not rails. RVM是Ruby版本管理器,而不是rails。 If that is the only version of rails you downloaded, you can start using it. 如果这是您下载的Rails的唯一版本,则可以开始使用它。 If you wanted to use a specific version of ruby, you would use that command. 如果要使用特定版本的ruby,则可以使用该命令。

To use a specific version of rails, use rails _3.2.0_ app_name . 要使用特定版本的rails,请使用rails _3.2.0_ app_name

Use 采用

gem list | grep rails gem list | grep rails to check your rails versions installed. gem list | grep rails检查您安装的rails版本。

rvm use 1.xx is to switch b/w ruby versions not rails versions rvm use 1.xx用于切换红宝石版本而不是Rails版本

rvm is for managing ruby interpreters. rvm用于管理ruby解释器。 With any modern rails app, just run 使用任何现代Rails应用程序,即可运行

bundle install

In the apps directory for all the required gems to be installed (including rails). 在apps目录中,用于安装所有必需的gem(包括rails)。 You'll need to install the bundler gem ahead of time but that's all 您需要提前安装捆绑包gem,仅此而已

RVM manages different ruby enviroment with different gemsets . RVM管理不同的ruby有不同的环境gemsets If you want to use different rails version with same ruby you can create different gemset to avoid conflicts. 如果要对同一ruby使用不同的rails版本,则可以创建不同的gemset以避免冲突。

Assume you have two different ruby versions 1.9.3 and 2.0.0 (which are installed using rvm ). 假设您有两个不同的ruby版本1.9.32.0.0 (使用rvm安装)。 By default it will have default gemset got created and uses that. 默认情况下,它将具有default gemset被创建并使用。

rvm list

gives: 得到:

=* ruby-1.9.3-p0 [ i686 ]
ruby-2.0.0-p0 [ i686 ]

# => - current
# =* - current && default
#  * - default

Assume you have rails 3.0.0 installed in default environment. 假设您在默认环境中安装了rails 3.0.0 And now you want to have one more rails version with different gemset you can create as follows: 现在,您还想使用不同的gemset来创建另一个rails版本,您可以按以下方式创建:

  rvm gemset create rails-3.2.8
  rvm use 1.9.3-p0@rails-3.2.8  # Switching enviroment

This will create different environment with ruby 1.9.3 and rails 3.2.8. 这将使用ruby 1.9.3和rails 3.2.8创建不同的环境。

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

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