Looking for Part 1?

First Steps with Ruby

The system I’m using for web development is a Mac running OSX 10.4.11 (Tiger). Ruby is installed by default in Tiger although it does need some tweaking to work properly with Rails (more of that shortly).

Using Cooper’s book I dived straight into it. Opening up Terminal you can quickly check which version of Ruby you have installed; at the command prompt type

ruby -v

and hit return. This will look something like this…

computer:~ user$ ruby -v
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.11.1]
computer:~ user$

So I’ve got Ruby 1.8.6 installed. It’s pretty easy to mess around with code examples in the Terminal using the Ruby interactive interpreter, “irb”. Enter

irb

and you’ll get:

irb(main):001:0

and you’re off and running. I did this for a bit and learned the basics of the Ruby syntax along the way but to be honest, my impatience was getting the better of me and I wanted to get Rails up and running ASAP.

Installing Ruby on Rails, Part I

You’ve got two main options when installing the Rails framework on Mac OSX; either manually, commonly using the guide provided by Dan Benjamin, or using the single installer Locomotive (although the latter is now finished development as the advent of a fully functional Rails stack in Mac OSX Leopard means it is no longer needed).

The “instant” results of Locomotive looked appealing so I had a go at this first. Downloading the file is straightforward enough, of course, and the install is a simple matter of dragging the package into the Applications folder. Starting up the app you get a control panel. To start a new Rails project, click the down arrow in the bottom left corner and select “Create New”. From there I created a project called “mydiary” in a rails directory of my home folder. So far so easy. Highlight the project in the Locomotive console, click run, and off it goes (it’s still empty of course). Browsing to http://localhost:3000/ gave the “Welcome to Rails” page expected. Beyond this though I became unstuck.

As detailed in both Beginning Ruby and on the Welcome to Rails page, the next thing you need to do is set up your database. With Locomotive installed, I should have MySQL running, but is it? I played about with this for a while and got nowhere near getting a basic app up and running. In truth, too, the Locomotive approach did leave a nagging doubt that I was missing some key understanding along the way.

So I returned to the manual method. I took a quick diversion first to look at Sakuzaku’s script that claims to automate the whole Hivelogic (Dan Benjamin) procedure. This could well be a nice compromise I thought. There’s some telling comments on the blog, however, from Dan himself pouring some rather icy water over doing it this way. I gave it a go though, but it all fell apart at the MySQL install. If you check out Sakuzaku’s page you’ll see mention of a possible MySQL error. This is pretty much what happened to me, but there is no obvious solution. So I ditched that too! There was nothing else for it: over to Hivelogic…

I’ll detail my experiences with Dan’s methods in Part 3.

4 Responses to “Ruby on Rails: A Newbie’s Journey, Part 2”

  1. Ruby on Rails: A Newbie’s Journey, Part 1 « facetsquared Says:

    [...] time (Part 2) I’ll relate my experiences with beginning programming in Ruby and installing Ruby on [...]

  2. matthewmcvickar Says:

    Hey there, sorry you had trouble with the script — what was the exact error you ran into?

  3. godflesh Says:

    Hi Matthew, thanks for commenting. To be honest I don’t have a copy of the exact error. It was getting real late and I just kind of threw in the towel when it failed! I felt I was getting too far out of my depth on the whole MySQL side. I’ve now got it all running using (with some minor mods - see “Part 3″ ;) Dan’s method. Sorry I can’t be more helpful on the script.

  4. Ruby on Rails: A Newbie’s Journey, Part 3 « facetsquared Says:

    [...] April 2, 2008 Looking for parts 1 or 2? [...]

Leave a Reply

You must be logged in to post a comment.