Using the Ruby on Rails web framework – How to install Rails and create a simple blog (Part 1)
This is a beginner’s guide to installing Ruby on Rails and creating a simple, secured blog relatively fast. Ruby on Rails is an open source MVC web application framework based on the Ruby programming language. It’s intended to be used with an agile development methodology that is used by web developers for rapid development. If you’ve not heard about the Agile development or the MVC concept, please read about them first, as you need to know about their basics to be able to understand all parts of this tutorial. Very basic knowledge of HTML and Ruby will be needed, too.
By default Ruby on Rails includes tools that make web development easier, such as scaffolding that can automatically construct some of the models and views needed for a basic website. Other tools are WEBrick, a simple Ruby web server and Rake, a build system. Together with Rails these tools provide a basic development environment.
Warning! I’ve created this simple blog application on my own web space that’s was hosted by Hostmonster, installing and using Ruby on Rails on other web hosting providers’ web spaces may (probably) be different and many of them won’t even support Rails. As I moved my website to an other hosting provider in January 2012, the working examples are no longer available here.
Before you start installing, I need to warn you again, that this guide is Hostmonster specific and the installation bit will only work if you have a Hostmonster account. If you’re not with Hostmonster, but you have Ruby on Rails set up on a different host or on your computer, skip steps 1, 2, and 3.
If your developing on Hostmonster, you need to have SSH access enabled. Here’s how to do this on Hostmonster.
WEBrick isn’t necessary on a Hostmonster account and you’re not supposed to use it. This is because Hostmonster wants you to develop on their server instead of developing your Ruby on Rails application on your own computer where there might not be an Apache install which is pre-configured to use Rails on Hostmonster. “Yay” for the pre-configured Apache, but “Booooooo” for forcing us to develop on the server…
Also, you should use MySQL on your Hostmonster account, hopefully this isn’t an issue.
To begin, log into the Hostmonster server using SSH (I use the free PuTTY software as an SSH client, but there are many similar ones on the net to download).
You’ll create a work directory and then cd into it. You can name it whatever you would like, such as “myrails”…
cd ~/myrails
Create an application called “myblog”. How you create the application depends on what version of Rails is running on the Hostmonster server (currently 2.3.5). To find it out use the following command…