Tools and Knowledge

I won't tell you which operating system you should use - there is an interesting discussion on hackernews. I'll leave it free for the reader of this book which to use, because you are reading this book to learn Padrino.

To actually see a running padrino app, you need a web browser of your choice. For writing the application, you can either use an Integrated Development Environment (IDE) or with a plain text editor.

Nowadays there are a bunch of Integrated Development Environments (IDEs) out there:

Here is a list of plain text editors which are a popular choice among Ruby developers:

  • Emacs - free, available for all platforms.
  • Gedit - free, available for Linux and Windows.
  • Notepad++ - free, available only for Windows.
  • SublimeText - commercial, available for all platforms.
  • Textmate - commercial, available only for Mac.
  • Vim - free, available for all platforms.

All tools have their strengths and weaknesses. Try to find the software that works best for you. The main goal is that you comfortable because you will spend a lot of time with it.

Installing Ruby With rbenv

Instead of using the build-in software package for Ruby of your operating system, we will use rbenv which lets you switch between multiple versions of Ruby.

First, we need to use git to get the current version of rbenv:

$ cd $HOME
$ git clone git://github.com/sstephenson/rbenv.git .rbenv

In case you shouldn't want to use git, you can also download the latest version as a zip file from GitHub.

You need to add the directory that contains rbenv to your $PATH environment variable. If you are on Mac, you have to replace .bashrc with .bash_profile in all of the following commands):

$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc

To enable auto completion for rbenv commands, we need to perform the following command:

$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc

Next, we need to restart our shell to enable the last changes:

$ exec $SHELL

Basically, there are two ways to install different versions of Ruby: You can compile Ruby on your own and try to manage the versions and gems on your own, or you use a tool that helps you.

ruby-build

Because we don't want to download and compile different Ruby versions on our own, we will use the ruby-build plugin for rbenv:

$ mkdir ~/.rbenv/plugins
$ cd ~/.rbenv/plugins
$ git clone git://github.com/sstephenson/ruby-build.git

If you now run rbenv install you can see all the different Ruby version you can install and use for different Ruby projects. We are going to install ruby 1.9.3-p392:

$ rbenv install 1.9.3-p392

This command will take a couple of minutes, so it's best to grab a Raider, which is now known as Twix. After everything runs fine, you have to run rbenv rehash to rebuild the internal rbenv libraries. The last step is to make Ruby 1.9.3-p392 the current executable on your machine:

$ rbenv global 1.9.3-p392

Check that the correct executable is active by exexuting ruby -v. The output should look like:

$ 1.9.3-p392 (set by /home/.rbenv/versions)

Now you are a ready to hack on with Padrino!

Ruby Knowledge

For any non-Ruby people, I strongly advise you to check out one of these books and learn the basics of Ruby before continuing here.

In this book, I assume readers having Ruby knowledge and will not be explaining every last detail. I will explain Padrino-specific coding techniques and how to get most parts under test.