-
Notifications
You must be signed in to change notification settings - Fork 25
Rails
This article assumes you are using OSX and that you've seen the command line before.
If you're new to the command line, consult the Terminal.app guide.
RVM lets you manage Ruby dependencies cleanly, which is important if you plan on developing more than one application on your machine. There are alternatives, but they are not covered here.
You should have RVM installed on your system. Check to see if you have RVM with rvm -v
.
If you don't have RVM, you'll need to install it. The RVM site has detailed installation instructions.
RVM calls each set of dependencies a "gemset", for reasons which will become clear. Let's make a new gemset called "client-app" with rvm gemset create client-app
.
Next, we have to activate the gemset with rvm gemset use client-app
.
Ruby software is packaged as gems, commonly fetched from rubygems.org. We can install new Ruby gems with the gem install
command. Let's install Rails with gem install rails
.
The gem install command can take a while, but in the end, we will have all the required gems:
RVM calls its sets of dependencies "gemsets" because each one contains a different set of gems.
Rails ships with a command line tool, which is used almost all Rails-related tasks, called rails
. We should make a new application using rails new client-app
.
This makes a new directory at ~/workspace/client-app
. We can see its contents using ls ~/workspace/client-app
.
This does almost all of what we want, except we also want to tell RVM about our gemset.
We need to tell RVM about our gemset with a file called .rvmrc
. Go into the new Rails application's directory using cd client-app
.
We can create the .rvmrc
file quickly by running echo "rvm use --create ruby-1.9.3@client-app" > .rvmrc
.
Now we need to trust the .rvmrc
file. In order to do this, for reasons beyond the scope of this document, we run cd ~/workspace/client-app
.
Now, we see a big warning, to which we answer yes
.
We now have a new Rails app, all dependencies and a trusted .rvmrc
!
Bundler, and its associated command line application bundle
, is used to manage Gems. Just in case some important software was released since you did that first gem install
, let's run bundle install
.
Now let's start Rails with rails server
.
You should now have a new Rails app at http://localhost:3000!