Tutorials

Installing and Running Ruby, Rails and Hobo on Windows

Oct 02, 2008 insic 1 Comment

First, I give you a little introduction about Hobo.

Hobo is a collection of open-source plugins for Ruby on Rails that help you build anything from throw away prototypes and internal utilities to meticulously crafted full-blown web apps. The goal: write less code. So much less in fact that it starts to feel like you’re not implementing your app at all, you’re just declaring what you want.

Part 1 of 2: Install and Use SQLite as the Database Engine

1. Download the latest stable Ruby version as a Windows installer executable file ruby186-27.exe from rubyforge.org:

http://rubyforge.org/projects/rubyinstaller/

2. Run ruby186-27.exe and install in the folder c:\Ruby.

3. Install the SQLite3 for Ruby gem using the “gem” command:

Open up the dos prompt (Start>Programs>Accessories>Command Prompt) and run the following from the c:\ruby folder.

C:\ruby> gem install sqlite3-ruby

commandline

Choose option 1 when prompted (mswin32)

4. MS Windows PCs also require the sqlite3.dll. Download this from http://www.sqlite.org/download.html place it the “c:\ruby\bin” folder.

Unzip the downloaded file and place the sqlite3.dll under c:\ruby\bin

sQLlite Dll

5. Install the latest version of Rails:

C:\ruby> gem install rails -–include-dependencies

6. Install the Hobo Support gem:

C:\ruby> gem install hobosupport

7. Install the Hobo gem:

C:\ruby> gem install hobo

8. Create a master application folder (e.g., HoboApps) on your drive of choice (e.g., C: This folder will contain all your applications.

At the command prompt, create a new Hobo application—for example, MyTestApp. Without specifying a database, SQLite will be used as default:

C:\HoboApps> Hobo MyTestApp

The following folders will be created under the Application folder.

Application Directory

9. Now prepare a simple data model using the hobo_model_resource command:

C:\HoboApps\MyTestApp> ruby script/generate hobo_model_resource mytask name:string due:date status:string

Notice what is created automatically:

New App Created

The Hobo user model was also created automatically by Hobo:

10. Generate the hobo_migration for these models:

C:\HoboApps\MyTestApp> ruby script/generate hobo_migration

Then select the “g” (generate) option and press to select the default migration file name.

11. Now implement the migration using the “rake” command:

C:\HoboApps\MyTestApp> rake db:migrate

This will create the tables in the development SQLite database. You can use a tool like SQLite Analyzer to see a detailed view of what was created:

12. You could run the app now with the default WeBrick server, but Mongrel is a better performer. Install the server gem:

C:\Ruby gem install mongrel –-include-dependencies

13. Change your directory in your command prompt to root of the new application, e.g.,

C:\HoboApps\MyTestApp>

In the command prompt, type “ruby script/server”:

C:\HoboApps\MyTestApp> ruby script/server

Now Ruby will boot the Mongrel server by default:

14. Load your browser an enter the URL accessing the default port: http://localhost:3000

Notice that Hobo uses the application folder name as the default title:

Choose the “Sign up” option. The first user to sign up will be given admin rights.

And there you go. Where done, login after you signup, and your app is ready for you.

About the author: insic

Subscribe in my RSS Feed for more updates on Web Design and Development related articles. Follow me on twitter or drop a message to my inbox.