How to set default rails version for a project?
I have installed two different rails versions in my system (Fedora).
gem list -d rails
*** LOCAL GEMS ***
rails (3.0.5, 1.2.1)
Author: David Heinemeier Hansson
Rubyforge: http://rubyforge.org/projects/rails
Homepage: http://www.rubyonrails.org
Installed at (3.0.5): /usr/local/lib/ruby/gems/1.8
(1.2.1): /usr/local/lib/ruby/gems/1.8
Full-stack web application fr开发者_运维百科amework.
When i try to create the project like following way ("http://www.nomachetejuggling.com/2008/03/12/using-multiple-versions-of-rails/")
rails 1.2.1 myproject
But, it's not working. So, i checked
rails -v
Rails 3.0.5
So, can you help me, how to create the project with older version and newer version. Is there any way to set the particular rails version as default?
To use an older version than the latest you have installed, just wrap the version number in underscores:
rails _1.2.1_ myproject
I couldn't get matkins' answer to work via RailsInstaller on Windows 7, so I thought I'd post my solution for someone else to benefit from: (I don't have the reputation to offer this as a comment so I'm adding a new answer)
c:\>rails -v
Rails 4.0.0
c:\>rails _3.2.8_ app1 &REM This is going to bug out
Instead, I found this works:
c:\>rails _3.2.8_ new app1 &REM This will work
The URL you posted solves your problem - you simply forgot the underscores.
varar:~ mr$ gem list rails
*** LOCAL GEMS ***
rails (3.1.0.rc1, 3.1.0.beta1, 3.0.3, 3.0.1)
varar:~ mr$ rails _3.0.1_ -v
Rails 3.0.1
As @Shaun mentioned in this post, you can use multiple versions of Rails and Ruby in same time!
For using an specific version of ruby:
rvm use 1.9.3 --default
Switch --default
is used for setting this version as Ruby default version.
For using an specific Rails and Ruby version:
rvm gemset create rails-3.2.3
rvm use 1.9.3@rails-3.2.3 --default
gem install rails
First line creates a gemset and related folder under /home/username/.rvm/gems/
Second line use that gemset as default one
Third line install specified version in gemset (Rails 3.2.3) on related folder.
This is my gems
folder's contents:
cache ruby-1.9.3-p194 ruby-1.9.3-p194@global ruby-1.9.3-p194@rails-3.2.3
Initial folder is ruby-1.9.3-p194@global
. Therefore for backing to previous state, just run:
rvm use 1.9.3@global
and you can see previous Rails and Ruby versions :)
Good luck
To create a project with the specific rails version use the below command: similar to matkins suggested
rails _5.0.7.2_ new <project_name>
In your config/environment.rb
file, place this at the beginning for the old version:
RAILS_GEM_VERSION = '1.2.1'
or this for the new version:
RAILS_GEM_VERSION = '3.0.5'
here is a general format example. feel free to modify as needed
rvm use ruby-2.1.0@rails4.2
You first installed a rvm(rails version management) then type. rvm 1.2.1
精彩评论