Difference between revisions of "RPi Ruby on Rails"

From eLinux.org
Jump to: navigation, search
m (Typo in prompt due to old TV)
m (Corrected meaning of RVM)
Line 9: Line 9:
 
The installation was all done from the basic (pre startx) command prompt.
 
The installation was all done from the basic (pre startx) command prompt.
  
This method uses the Ruby Version Manager ([http://beginrescueend.com RVM]), so first we must install all its prerequisites:
+
This method uses the Ruby enVironment Manager ([http://beginrescueend.com RVM]), so first we must install all its prerequisites:
  
 
  # Install prerequisites<!-- I suspect there will be many more required to make Rails do anything useful (like sqlite) but waiting until I have a project running to optimise the list against already installed items -->
 
  # Install prerequisites<!-- I suspect there will be many more required to make Rails do anything useful (like sqlite) but waiting until I have a project running to optimise the list against already installed items -->

Revision as of 14:40, 25 April 2012

Installing Ruby on Rails on Raspberry Pi

This guide is aimed at developers, although it can be used by beginners if they know what they are after. It is provided as neither Ruby or Rails are included as standard in Debian "squeeze". Other Linux RPi distributions may contain this by default.

THE GUIDE IS STILL DRAFT; IT NEEDS FURTHER TESTING/OPTIMISATION AND EXPANDED EXAMPLE PROJECT.

Start with a clean image of Debian "squeeze". There is not enough room on a standard 2Gb image. I tested with an 8Gb image, but you may get away with 4Gb.

The installation was all done from the basic (pre startx) command prompt.

This method uses the Ruby enVironment Manager (RVM), so first we must install all its prerequisites:

# Install prerequisites
sudo apt-get install -y git
sudo apt-get install -y curl
sudo apt-get install -y zlib1g-dev
sudo apt-get install -y subversion

Now we can use RVM straight from github using:

curl -L get.rvm.io | bash -s stable --rails

Note: With my default Debian image and keyboard map, it was very hard to get a | (pipe) character. I got it by pressing AltGr+|

When run, you will get some messages about requirements for Ruby. You need to scroll down (TODO Confirm this is necessary) until you see "Press 'q' to continue.", then press 'q'. Note the computer may not react straight away as it is 'thinking'. After a few seconds, the script will download and compile ruby 1.9.x and rubygems (gem command). This takes a long time! (3 Hrs) Have a sleep and check in the morning. The above step has been successfully performed on a real RPi, but not managed to complete successfully on Qemu.

Now you should have ruby:

pi@raspberrypi:~$ ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [armv61-linux-eabi]

And you should have a rails command:

pi@raspberrypi:~$ rails -v
Rails 3.2.3

Testing Installation

In order to test the installation, let's create a simple project. My first attempt at this filled the OS partition on the SD card, so need to try where there is space. In this example the name for our new project is register.

rails new register
cd register
rails s