Badblog

welcome to our blog

We are Learncodz.


Posts

Comments

The Team

Blog Codz Author

Connect With Us

Join To Connect With Us

Portfolio

    Posted by: Anonymous Posted date: 10:07 / comment : 0

    Ruby on Rails is quickly becoming more and more popular every day. Learning to develop in the Ruby language is a very valuable skill. In this tutorial I’ll show you how to install Rails onto a Raspberry Pi.
    • Raspberry Pi (Model B)
    • SD Card (running Debian Squeeze)
    • Micro-USB Power Cable
    • Ethernet Cable or USB Wi-Fi Adapter
    • USB Keyboard
    • USB Mouse (preferable, but not required)
    Using SSH, or Secure SHell, will allow control the Raspberry Pi from another computer. In order to enable SSH, you must obtain the IP address of the Pi. To do so, type the following command into the LXTerminal application:
    You'll then see something similar to this:


    If you're using a wireless connection, in the wlan0 section, the IP address can be found on the second line, labelled inet addr. In this case, my IP address is 192.168.1.80.
    If you're using an ethernet connection, the IP address of the Pi can be found in the eth0 section.
    Enable SSH and then restart the Pi by typing the following commands into the LXTerminal window:
    You should enter each line one at a time, and press the Return key after each line has been entered.
    On a Mac, open up Terminal, which can be found within the Applications > Utilities folder. Type the following command into the window:
    You should replace 192.168.1.60 with your own IP address. You'll then be asked for the password. Unless you've previously changed it, the password will be raspberry. Whilst you won't see each character being typed on the screen what you're typing is being entered.
    If a security warning is displayed, double check that everything is ok, and then type either y or yes to continue the connection.
    If you've connected successfully to the Pi, you'll see pi@raspberrypi ~ $ being displayed at the bottom of the Terminal window, similar to this:


    You should begin by installing the prerequisites, to prepare for the installation of Rails. Type the following command into the Terminal window, once you've connected via SSH.
    If you come across a 404 Error, you'll likely need to update the package index, and this can be done using the following command.
    Whilst you're already getting the required packages, you'll need to retrieve the SSL package, SQL database package, and more.
    Open up the RVM, straight from its repository on GitHub.
    Once you've successfully installed the required packages, and have opened up the RVM, it's recommended that you run a script, just so that you can enable Ruby.
    You should now have successfully installed Ruby, and Rails. You can test for Ruby by typing the following command.
    If installed correctly, you'll see a message confirming which version of Ruby is installed, when it was produced, and what it's using in order to work correctly.
    You can also test for Rails by typing in the following command.
    As Rails required a JavaScript runtime, you'll need to install a new Ruby gem called ExecJS, and then install a JS package. You should begin by installing the gem.
    As stated on the ExecJS GitHub repository, ExecJS supports all of the following runtimes:
    • therubyracer
    • therubyrhino
    • Node.js
    • Apple JavaScriptCore
    • Microsoft Windows Script Host
    Install Node.js, by typing in the following command:
    In order to test that Rails is fully functional on the Raspberry Pi, create a simple project, by adding a new project, going to its directory, adding a scaffold, migrating the database, and then starting up the server.
    Begin by creating a new Rails project, called tutorials.
    Go to the new directory you just created:
    You can now create a simple scaffold, called Steps by running the following command:
    Now migrate the database using the following command:
    Start the Rails server:
    If all's gone well, you'll see the new project in action in the browser by typing the IP address, followed by the port number (3000 for Rails), and then by the project name. For me, that'd be the following address.
    That's it! You've successfully installed Ruby on Rails on a Raspberry Pi!
    You began by enabling SSH, then installing the required software in order for Rails to function properly.
    The best way to find out what you can do with your new Rails Server would be to play around with it, and see what it can do!

    icon allbkg

    Tagged with:

    Next
    Newer Post
    Previous
    Older Post

    No comments:

Comments

The Visitors says
Download Free Software Latest Version