简体   繁体   English

在rails旧版本中创建一个新项目

[英]Create a new project in rails older version

I have rails version 3.2.1 in my machine. 我的机器上有导轨版本3.2.1。 The other versions installed are 3.0, 3.0.3. 安装的其他版本是3.0,3.0.3。 Whenever i run 每当我跑步

 rails new PROJECT_NAME

command ,the project gets created in version 3.2.1. 命令,该项目在版本3.2.1中创建。 I want to create the project in version 3.0.3. 我想在3.0.3版本中创建项目。

What should i do? 我该怎么办?

you can create new app with older version 您可以使用旧版本创建新应用

rails _3.0.3_ new appname 

but you may get error as 但你可能会得到错误

/usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:316:in bin_path': can't find gem railties (["3.0.3"]) with executable rails (Gem::GemNotFoundException) from /usr/local/bin/rails:19:in ' /usr/local/lib/ruby/site_ruby/1.9.1/rubygems.rb:316:in bin_path':找不到railties (["3.0.3"]) with executable rails (Gem::GemNotFoundException) from /usr/local/bin/rails:19:in gem railties (["3.0.3"]) with executable rails (Gem::GemNotFoundException) from /usr/local/bin/rails:19:in '

so 所以

again install rails gem 再次安装rails gem

sudo gem install rails -v="3.0.3"

now you can do 现在你可以做到

rails _3.0.3_ new app

it will work fine 它会工作正常

thank you 谢谢

You could use something like RVM and install the other rails versions in a different gemset. 您可以使用类似RVM的东西,并在其他gemset中安装其他rails版本。 Then select the gemset with an older rails version and your rails command should be from the older version. 然后选择具有较旧rails版本的gemset,并且rails命令应该来自旧版本。

Alternatively you should be able to use 或者你应该可以使用

rails _VERSION_ new myapp

Suggest using bundler. 建议使用bundler。 Your project will have a Gemfile in which you specify the rails version you want: 您的项目将有一个Gemfile,您可以在其中指定所需的rails版本:

gem "rails", "~> 3.0.3" 宝石“rails”,“〜> 3.0.3”

Once you have installed the bundler gem, bundle install will install the version of Rails you have specified. 一旦安装了bundler gem, bundle install就会安装你指定的Rails版本。

Then, when you are ready to upgrade your version of Rails, you do this by specifying the version number you want to move to. 然后,当您准备升级Rails版本时,可以通过指定要移动到的版本号来执行此操作。 Of course, this approach helps manage all of the gems that your project depends on, including the ones you only want in test and dev etc. 当然,这种方法有助于管理项目所依赖的所有宝石,包括您在测试和开发中仅需要的宝石等。

See http://gembundler.com/ for more. 有关更多信息,请访问http://gembundler.com/

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

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