简体   繁体   English

在rails 2.2.2中创建一个新的rails项目(同时具有rails3)

[英]creating a new rails project in rails 2.2.2 (while having rails3)

In my computer (linux - ubuntu) I have installed rails 2.2.2 and rails 3 在我的计算机(linux-ubuntu)中,我已经安装了rails 2.2.2和rails 3

Now i want to create a project in rails 2.2.2. 现在我想在Rails 2.2.2中创建一个项目。 (Like rails ). (就像导轨)。 But it asks to enter the rails command as in rails 3 (like rails new ) 但是它要求像在rails 3中一样输入rails命令(例如rails new)

when i type rails -v it shows the rails version as 3. But in my gem list it has both rails 2.2.2 and 3 当我输入rails -v时,它会显示rails版本为3。但是在我的gem列表中,它同时具有rails 2.2.2和3

how can i create a project in rails 2.2.2 我如何在Rails 2.2.2中创建项目

thanks in advance 提前致谢

cheers 干杯

sameera sameera

Generally speaking if you have two versions of ruby and rails installed the last one will be the "normal" one using "normal" commands like: 一般来说,如果您安装了ruby和rails的两个版本,则最后一个将是使用“ normal”命令的“ normal”版本,例如:

ruby
rails
gem

For all the other versions you can define (or have defined during installation) some aliases like: 对于所有其他版本,您可以定义(或在安装过程中已定义)一些别名,例如:

ruby187
rails222
gem222

Another solution could be this 另一个解决方案可能是这样

Or the best solution I recommend for working with multiple ruby and rails versions is RVM 或我建议用于多个红宝石和导轨版本的最佳解决方案是RVM

You can do this. 你可以这样做。 Create a rails project. 创建一个Rails项目。

rails myproject

Go to your envirnonment file and modify to 转到您的环境文件并修改为

RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

EDIT 编辑

Yes , Sorry about that .This method may have worked in rails versions < 3. My Bad ! 是的,很抱歉。此方法可能在<3的rails版本中有效。 RVM the way to go. RVM的发展之路。

Should do the trick. 应该做到的。 Also I recommend you update to atleast Rails 2.3.9, in case you don't want to start off with Rails 3. 另外,如果您不想从Rails 3开始,我还建议您更新到至少Rails 2.3.9。

There are 3 easiest ways how to manage it: 有3种最简单的管理方法:

0) remove not used version of rails 0)删除不使用的滑轨版本

1) rails is just simple command, so each time when you need to run special version of it you can specify full full path to it( or alias it one time) 1)rails是简单的命令,因此每次需要运行它的特殊版本时,都可以指定它的完整完整路径(或一次别名)

2) if you strongly need to have different types/versions of ruby environments( and/or different versions of ruby gems such as rails), I recomend you to use rvm - it is the most easiest way to manage it. 2)如果您强烈需要使用不同类型/版本的红宝石环境(和/或不同版本的红宝石宝石,例如rails),建议您使用rvm-这是管理它的最简单方法。

当您想将已安装版本的一个版本专门用于特定项目时

rails _2.2.2_ (your project)

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

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