Installing HOBO on Windows with MySQL


In November I was asked to install HOBO, an excellent extension to Ruby on Rails, on a Windows PC, using MySQL as its database. HOBO is new, and at the time, only compatible with Rails 2.  So I learned Rails 3 from a book and used various websites to fill the gaps.  (See links at the end.) The version numbers are important.  I believe these combinations work:

  • Ruby 1.8.7
  • Rails 2.3.10
  • MySQL 5.0.83
  • HOBO 1.0.2

Here, I’ve used the stable releases.  Note, the Rails syntax changes between versions 2 and 3. 1. Before we begin, let’s get a good, free editor that recognises Ruby syntax: Komodo Edit

2. Download and install Ruby 1.8.7

3. Install the MySQL/Ruby connector gem

  • open a console (XP/Vista: Start, Run, “cmd”) (Win 7: Start, Search, “cmd”)
  • run cd \Ruby187
  • run gem install mysql, Ignore “No definition for…” errors if they show

4. Download the MySQL 5.0 installer

5. Copy libmySQL.dll to Ruby

  • copy from C:\Program Files\MySQL\MySQL Server 5.0\bin
  • copy to C:\Ruby187\bin

6. Install Rails 2.3.10 gem

  • in a console, still in the Ruby187 directory
  • run gem install rails –version 2.3.10

7. Install HOBO Support gem

  • in a console, still in the Ruby187 directory
  • run gem install hobosupport

8. Install HOBO gem

  • in a console, still in the Ruby187 directory
  • run gem install hobo

9. You are now ready to build your first HOBO application.

  • create a directory C:\HoboApps\ (in Explorer, or the console with mkdir)
  • in a console, cd \HoboApps
  • run the command hobo -d mysql MyTestApp
  • this will create several directories and files in C:\HoboApps\MyTestApp

10 You need to make sure the username and password you set up for MySQL is correct in the project.

  • in the Komodo Edit editor, open C:\HoboApps\MyTestApp\config\database.yml
  • in the “development” section, update the username and password fields
  • save the file

11. Create a simple data model.  All work for a Rails/HOBO app is done in its directory.

  • in the console, cd MyTestApp
  • run the command ruby script/generate hobo_model_resource mytask name:string due:date status:string
  • this creates the MyTask model, and the User model is also created by HOBO

12. In MySQL installations, this step may be necessary, to initialise the database.

  • in the console, still in the MyTestApp directory
  • run the command rake db:create

13. Generate the hobo_migration for these two models

  • in the console, still in the MyTestApp directory
  • run the command ruby script/generate hobo_migration
  • then select the “m” (migrate) option and accept any default settings then select the “g” (generate) option and press to select the default migration file name

14. [This step is covered automatically by “migrate” above, so  unless you chose “g” (generate) instead of “m”,  skip it!] Now implement the migration using the “rake” command

  • in the console, still in the MyTestApp directory
  • run the command rake db:migrate
  • this will create the tables in the development MySQL database – you can use the usual mysql command to have a look at these, or the Rails console tool

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

  • in another console, cd \Ruby187
  • run the command gem install mongrel
  • back in the first console, still in C:\HoboApps\MyTestApp directory
  • run the command ruby script/server
  • now Ruby will boot the Mongrel server by default
  • Press Ctrl+C to stop it.

16. Load your browser, 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. This document is based on http://blog.insicdesigns.com/2008/10/installing-and-running-ruby-rails-and-hobo-on-windows/, with help from