The first part of the Rails 4 tutorial is actually getting Rails 4 without messing up your existing Rails 3 install. The other parts of this tutorial can be found at the index, or by hitting the tutorial menu above and selecting the Rails 4 tutorial option.
We’re going to use RVM to create a separate gemset for ruby 2.0.0, which should give us separation between our projects.
Review the documentation on RVM, and download and install RVM if you haven’t already got it. If you didn’t already have RVM (many setups come with it standard) you probably want to be careful as you create the gemset for ruby 2.0.0, make sure you haven’t broken your old gemset(s).
First, ask RVM to install ruby 2.0.0 for you:
rvm install 2.0.0
Next, create the project directory, I’m calling mine league-tutorial-rails4, and if you call yours that it’ll match what you get if you clone the code from github:PaulL. Go into that directory:
And tell rvm that this project uses ruby 2.0.0:
rvm use 2.0.0
Following the instructions at , we install rails 4.0.0:
gem install rails --version 4.0.0 --no-ri --no-rdoc
Make sure you don’t use
sudo, you want rvm to be managing this for you. This should now have given you a gemset with rails 4 in it.
Next, go back up a directory, and ask rails to create the application over top of your directory:
cd .. rails new league-tutorial-rails4
We’d like rvm to automatically change versions for us. Our research starts at stackoverflow, but ending up in the rvm documentation, we learn that we used to use a
.rvmrc file to control versions. However, this file also allows arbitrary scripting, which makes it a security issue of you take it all the way to production. Instead, we ask rvm to create a
.ruby-version file for us, and optionally, a
rvm --ruby-version use 2.0.0
This should create a
.ruby-version file, and whenever you come into the folder rvm should change to 2.0.0 for you automatically. If you had a gemset (in the form 2.0.0@myGemset) then it would also have created a
.ruby-gemset file for you.
If this isn’t working for you, now’s the time to sort it out, and it’s most likely due to your profile settings (some rvm-specific variables need to be set on login). You may find that if you’ve only just installed rvm, that closing all your terminal sessions and reopening may fix it (i.e. the variables may have been added to your profile, but don’t take effect unless you either log in again, or
You can verify this is working by changing between your folders and issuing:
ruby --version rails --version
It should be changing between the projects, and should be 2.0.0 / 4.0.0 for the tutorial.
Make sure you have everything working cleanly, and then move on to creating the application itself in the next tutorial step.