Ruby on Rails – Part 1

I have decided to have a play with Ruby on Rails. I had a go about a year ago but got nowhere as I had problems installing rails on my Windows Vista PC.


This time around I decided to forego the one click install and do everything manually. I followed the instructions from this page.

To summarise ….

  1. Install version 1.8.6 r26 of ruby, downloaded from here
  2. Open up a command prompt
  3. Confirm you have ruby installed by running ‘ruby -v‘, you should see a message like this ‘ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
  4. Check which version of gem you have installed by running ‘gem -v‘. You’ll need version 1.0.1 or higher, to updgrade just run ‘gem update –system
  5. I already had subversion installed, so didn’t need to follow that part of the instructions
  6. I also wanted to use MS SQL as I already have that installed and am familiar with it, so I skipped the next section
  7. Next I installed rails and it’s dependencies by running ‘gem install rails capistrano mongrel mongrel_cluster
  8. As I am only trying this all out locally I didn’t bother installing a SSH client
  9. The final step was to get the MSSQL adapter working. To get that working I followed the instructions in a book I have

Getting the MSSQL adapter working

  1. Create a new ADO folder under your rubylibrubysite_ruby1.8DBD folder
  2. Download the source distribution of Ruby-DBI
  3. Unzip the ADO.rb file in the srcibdbd_ado folder within that zip/gz file

Creating your first Ruby on Rails application

  1. Open up a command prompt if you don’t already have one open.
  2. Go to the folder where you’d like to keep all your ruby projects in.
  3. Run ‘rails blog‘, this will create your application.
  4. Change into the newly create folder by running ‘cd blog
  5. Start the server by running ‘ruby script/server‘, wait until you see this message appear, ‘** Use CTRL-C to stop.
  6. Check that your application is working correctly, by opening up your web browser and navigating to ‘http://localhost:3000‘, you should now see a welcome screen.
  7. Click the ‘About your application’s environment‘ link to check everything is working.

I was actually trying to follow this tutorial video when I got slightly stuck on the database and web server side of things. So I’m about 22 seconds into that tutorial !!

If you’re using MSSQL you will probably see an error message relating to the database connection. To correct this you will need to edit your database.yml file, this is found in the config folder of your project folder. In my case that was blogconfig. You will need something along these lines…

  adapter: sqlserver
  database: blog
  host: .
  username: <username>
  password: <password>

Oh, and don’t forget to actually create the database.

Now close your application by going back to the command prompt and hitting Ctrl-C. Now run ‘ruby script/server‘ again. Refresh your browser and try click the ‘About your application’s environment‘ link again. Hopefully, you should see some useful information instead of an error message.

That is as far as I have got, which to be honest is a lot further than I got the last time I tried my hand at this. So, I think that’ll do for “Part 1” as it’s getting late and I have to get up early tomorrow morning for rowing training 🙂

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s