How do I switch to older versions of the ruby/rails environment?
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
How to switch to an older version of rails
First, uninstall the version of Rails you have:
gem uninstall rails
Next, install the version of Rails you want, like so:
gem install rails -v 3.1.12
There are a few ways to have both "installed" at the same time. As Joe Frambach suggested, you could install Rails 4 in a VM. You could also install RVM - the Ruby enVironment Manager - and use separate gemsets to keep the two versions of Rails apart. But if you are just learning you may not want to bother with this.
Edit: @Shadwell's answer got it right, although it could use some expansion, which I'll do here:
> rvm gemset create rails3
> rvm gemset use rails3
> gem install rails -v 3.1.12
> rails my_new_app
Change version of rails
Try this:
rvm use <ruby version>
You can also check your installed ruby versions using rvm list
and then switch over. Then do:
rvm gemset create rails3.2.13
rvm <ruby version>@rails3.2.13
gem install rails --version=3.2.13
Ruby on Rails - Need to use an older version of ruby for an app
Personally I would leverage a Ruby version management tool such as rbenv or RVM to install multiple versions of Ruby. To accomplish this on Windows you would need to use a different terminal/shell such as GitBash or Ubuntu Bash on Windows. I highly recommend doing this anyways when doing development on Windows.
Uninstalling Ruby to go to an older version
Linux users: please remember that not everyone is interested in switching their OS, running 2 machines, trying to figure out dual boot, or dealing with virtual machines dragging down a host. While Linux is a great environment for software development, people, like the OP, just looking to try their hand at something (like ruby/rails) should not immediately be told to switch to something completely unfamiliar which might not even adequately support their normal day to day activities.
Since I am not a believer in making anyone leave an environment they are comfortable with (especially since you stated "learning". Why would you want to make an additional investment just to try something out?) and because I did not want my comment to get over looked as it will help with your issue, I have decided to post this as an "answer".
Mac and Other *nix based OS's have the ability to install rvm
(Yes I know there are more but rvm
is my personal choice and a community favorite) which allows you to manage different versions of ruby on the same OS.
While rvm
is not available for Windows there is a small application called uru
which will get you as close from a windows standpoint.
Installing a version manager means that you do not need to uninstall or rollback anything you can simply install a new/old ruby version side by side the current versions you have and switch between them fairly easily from command line.
While uru
does not have all the fancy features that other applications like rvm
possess (by design). It contains the important ones (primarily in your case switching ruby versions). The CLI is very simple and straight forward. Examples of uru Usage
Also: Please note I work in an Windows centric Office and have developed more than a few fully functional rails applications on a windows machine. Yes there are some headaches when dealing with native extensions and know that you will always be slightly behind the leading edge for ruby and rails but it is completely possible and feasible to build enterprise level web applications completely in a Windows environment without ever installing Linux at all. (Note I do use dedicated Linux machines for non development web servers)
Controlling ruby version used in Rails
https://rvm.io/rvm/install
Install RVM using these instructions, then you can manage and switch between different Ruby versions and gemsets very easily. Using RVM you can have both 1.8.7 and 1.9.x (or any other version) on your system without having to constantly manually change your path and ruby alias.
Older versions of RVM used the .rvmrc
file to automatically switch the ruby within a directory. Newer versions use the .ruby-version
file.
To switch between rubies, just type rvm use 2.0.0
or whatever version it is you want to use. For ongoing projects it's a good idea to add the .ruby-version
file in the root of the directory that contains the version string you want to use, i.e.
2.0.0
Installing old versions of Ruby and Rails
Create two files for the project: A file called .ruby-version
which should have 2.1.2
in it, and a file called .ruby-gemset
which should have the name of the project in it.
cd
into the directory, and RVM will setup an environment where you can just run bundle
and have the old version of Rails install without conflicting with your other versions you may use.
This will also allow you to bump down the Ruby version if you need to.
Specifying rails version to use when creating a new application
I found here an undocumented option to create a new application using an older version of Rails.
rails _2.1.0_ new myapp
Related Topics
Building a Windows Executable from My Ruby App
App Pushed to Heroku Still Shows Standard Index Page
Namespacing Thor Commands in a Standalone Ruby Executable
How to Structure a Layout Template in Haml
Carrierwave Crop Specific Version
Ruby: How to Make a Public Static Method
Ruby: How to Count the Number of Times a String Appears in Another String
Ruby Koan 151 Raising Exceptions
Ruby Concatenate Strings and Add Spaces
Rails: Logging for Code in the Lib Directory
Comparing Times Only, Without Dates
Unit Test in Rails - Model with Paperclip
Passing Param Values to Redirect_To as Querystring in Rails
Rails: How to Show User's "Last Seen At" Time
Sorting a Two-Dimensional Array by Second Value
Catching Line Numbers in Ruby Exceptions
Rails: Validating Min and Max Length of a String But Allowing It to Be Blank