I've just upgraded my rails version to rails 3.0.
But suddenly I need a new rails app with old version of rails.
I know the new version of rails change command line usage with rails new.
How can I create an old version of Rails in this new Rails 3 environment?
Use the following command:
rails _2.3.5_ new APP_NAME
This will create a rails project with version 2.3.5
Leonid Shevtsov provided instructions for how to do this here.
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Runbundle install
Run bundle exec rails . to create an app in the current path
You don't even need rvm to do this.
If you need to switch back and forth, I would recommend using RVM. You can install different versions of Ruby and each can have its own set of gems. I use my system installed ruby (1.8.6?) on my Mac for Rails 2 dev, and then I installed Ruby 1.9.2 with RVM for my Rails 3 dev. Its as simple as doing this after you have RVM installed:
#install and use 1.9.2 for Rails 3
rvm install 1.9.2
rvm 1.9.2
rails new whatever
#switch back to system installed ruby for Rails 2
rvm system
rails whatever
Related
I'm new to rails. After finally getting my environment to work properly with RVM 2.0.0 rails 4.0.5, all of a sudden rails disappeared and I keep getting the message: Rails is not currently installed on this system...
When I quit terminal, reopen it, and type:
$ rails v
It shows 4.0.5
However, as soon as I change directory into my rails app and check the rails version I get the message that rails is not installed.
Any idea what's going here?
When you use rvm you have multiple versions of ruby installed. You select which one you want like this:
rvm use 2.0
or
rvm use 2.1
You can also specify a ruby version in a .ruby-version file in a directory. Then when you change to that directory in the terminal, RVM will switch versions for you.
Each version of ruby has its own set of installed gems. Rails is a gem.
Ergo, when you installed rails, you were in your default ruby version (probably the one build-in on your system). When you change directory to your rails application, RVM is kicking in to switch to the correct ruby version for you. But you don't have rails installed in that version.
So the solution is to switch to the directory for your rails app and run:
bundle install
This will install your gem bundle for your application, including the rails gems, and it will do it into the correct ruby version.
Currently Rails 4.0.2 is installed in my Windows machine and I'm using it for several rails projects. But, I do want to use Rails 3.2.8 version for another project.
So, my question: Can I specify the version 3.2.8 on a single project and retain 4.0.2 in all the rest by ensuring all dependencies for 3.2.8 are installed?
Yes !
Install the rails 3.2.8 gem.
Then, you can specify which version of rails you want to use :
rails _3.2.18_ new mySuperSecretProject
In each project, you can use rails _xxx_ console, but it is easier do directly use the binstubs : bin/rails console
Yes you could do it as Intrepidd stated.
Another way to do this is by including a specific gem version in your application Gemfile and then do a bundle install. This will tell the application to use that particular version of rails over your system version
Rails can be installed as follows:
1) Specify the rails gem version in your project Gemfile
gem 'rails','3.2.8' OR gem 'rails', '4.0.2'
2) Try running bundle install. it will automatically install required rails version for you and will create a bundle unique for the project you are in.
3) For rails 4.0.2 project: if rails 3.2.8 is already installed, try running 'bundle update rails' to upgrade the current rails version and it will install all of its dependencies in the corresponding bundle.
If you want to run these projects in different ruby versions, then in Linux platforms RVM is the best option. But, in windows RVM will not work. A good option will be the Pik tool. Pik is a tool to manage multiple versions of ruby on Windows.
Please refer here for the same. Hope it helps :)
I am working on Ubuntu . Initially I have 3 version of rails installed 3.2.9 , 3.2.12 and 4.0.0 . Running rail -v was showing Rails 4.0.0 . I tried to uninstall Rails 4.0.0 using gem uninstall rails 4.0.0 . Now Running gem uninstall rails gives this output:
Select gem to uninstall:
1. rails-3.2.9
2. rails-3.2.12
Running rails -v now also gives Rails 4.0.0 .Any guesses how can i change default rail to 3.2.12.
Investigating more on Thaha kp comment, I found this:
rails _3.2.12_ new myapp # slightly different version positioning
that means, you can install as many rails versions you want in one ruby environment, and when you start a new app you just need to specify what version to use.
Now if you started your app in rails 3.2.10 and want to upgrade to rails 3.2.11 you just change the version in your Gemfile as Bharath Sankar suggested, after a running bundle your app will use 3.2.12 version.
I have 2 different Rails Rubygems installed on my Linux OS [2.3.8 and 3.0.3], but the current active Rails version is 3.0.3. So is it possible to generate Rails app using 2.3.8 style generator:rails testapp not new one: rails new testapp?
You can tell Rails to use version 2.3.8 like this:
rails _2.3.8_ testapp
I'd recommend installing RVM and setting up different gemsets for each version of Rails. That way you can easily switch between Rails versions by just switching gemsets.
See here: How to use the Rails 2.3 app generator when I have Rails 3 installed?
Quoting Leonid Shevtsov:
The easiest way to do it was:
Create the directory for the project
Create a Gemfile there containing
gem "rails", "2.3.9"
gem "sqlite3-ruby", :require => "sqlite3"
Run "bundle install"
Run "bundle exec rails ." to create an app in the current path
You don't even need rvm to do this.
You could also use rvm.
I'm trying to keep along with the Tekpub Build your own blog on rails screencast. I'm still very much a ruby novice and the problem is that I have Rails 3 installed while Rob uses an older version (Of the top of my head: version 2.3.2).
I know how to get that version of rails with gem install rails --version=2.3.2 but when I type rails new the version of the application is rails 3. How do I make this particular app work with the older version? I know this has something to do with rvm but I have no idea how to do anything but the basic rvm use operation.
Try,
rvm use <ruby version>
rvm gemset create rails2.3.2
rvm <ruby version>#rails2.3.2
gem install rails --version=2.3.2
Finally the syntax to create a new rails app in older versions of rails was just:
rails <appanme>
For more information about gemsets:
RVM: Named Gem Sets
This will install Ruby 1.8.7 and then create a gemset that will contain only a specific set of gems:
rvm install 1.8.7
rvm --create use 1.8.7#old_rails
gem install rails --version=2.3.2
Whenever you want to use this after the first time just:
rvm use 1.8.7#old_rails
.rvmrc files are really useful for automatically managing different sets of Ruby versions and gems. If you create file called .rvmrc in the project directory and put this line in it:
rvm --create use 1.8.7#old_rails
Then every time you cd into that directory RVM will switch to Ruby 1.8.7 and the gemset "old_rails". Have a look at the docs for .rvmrc here: http://rvm.beginrescueend.com/workflow/rvmrc/
Of course you can change "1.8.7" for "1.8.6", "1.8.7-p249", "ree-1.8.7-2010.02" or any other Ruby version you like, I just assumed that you would want 1.8.7.
Have a look at RVM (Ruby Version Manager)