Ruby on Rails for a dummy (me)

Posted by Betsy on September 2, 2009 in OpenSource |
Hello, Ruby on Rails!

Hello, Ruby on Rails!

I know – the above app isn’t much, but oh, the time it took me to get it working!

I’ve been trying to follow a Lynda.com video tutorial on Ruby on Rails – just the part about getting started! – for a couple of weeks now. The first stumbling block is that the tutorial was done on a Mac, and it doesn’t give very detailed advice for Windows users. (I am running Windows Vista, not as a lifestyle choice, but because I am poor. Don’t judge!) Here is what I tried:

  • Downloaded InstantRails. (Go ahead – just try to find their download page! I dare you!) Although everything seemed to be working here, commands like “script/generate controller say” didn’t work. Well, if that doesn’t work, it’s a wash.
  • Installed Ubuntu as a virtual machine. Followed several tutorials on how to install RoR, but all seemed to leave me with database connection problems.
  • Installed Turnkey Rails as a virtual machine. Oh, the joy I felt when I realized that to view my RoR app, I needed to use the browser on my non-virtual machine (i.e., Vista)! Why isn’t that made explicit anywhere? Once you figure that out, the GUI for Turnkey is really great – and the documentation is crap. I could not connect properly to the database with this one either.
  • Installed Bitnami as a virtual machine. Ugh, this is one is frustrating. I don’t even want to talk about it. The documentation is worse than for Turnkey.

So, one InstantRails and three virtual machines later, I was about ready to give up. However, I was feeling a bit better informed about how RoR functions because of all my failed interactions with it, so I decided to give InstantRails one more try. For anyone out there who is struggling and Googling vainly, here is what you do:

  1. You’re starting with a Windows Vista system.
  2. Download InstantRails. Choose the .zip file closest to the top of the page.
  3. Extract InstantRails somewhere convenient, such as a folder on the desktop. It’ll be staying there, rather than installing itself somewhere else. Get yourself a beverage because the extraction will take some time.
  4. Open the extracted folder and double-click “InstantRails.exe.”
  5. A dialog box will pop up. Just agree to let it do its thing.
  6. The program will look like this:
    Instant Rails
  7. If MySQL doesn’t say “Started” after a few seconds, click “MySQL” and choose “kill.” That should fix it!
  8. Now, to build your very own “Hello World” app, click the “I” button on the far left.
  9. Choose “Rails Applications” -> “Manage Rails Applications.”
  10. There are some prebuilt applications here that you can play with, but let’s face it – that’s not why you’ve installed RoR. Click “Create New Rails App…”
  11. A command prompt will pop up. Type the command below, where “myapp” is the name of the app you are going to create:
    rails myapp
  12. A list of lines should be spat out, each starting with “create.” Go back to the “Rails Applications” window and click “Refresh” at the bottom. “myapp” should now appear in the list.
  13. Go back to the command prompt and type the following command to change into the directory of your new app:
    cd myapp
  14. Type the following command to generate a controller called “say.” Note that you need to start the command with “ruby” or it won’t work! The direction of the slash doesn’t seem to matter, however. (Both \ and / worked for me.)
    ruby script\generate controller say
  15. Now you can edit the “say” controller to define an action called “hello.” Inside the InstantRails folder on your desktop, use a text editor to open “rails_apps” -> “myapp” -> “app” ->  “controllers” -> “say_controller.rb.”
  16. Add two lines to make it look like this:
    class SayController < ApplicationController
       def hello
  17. Save the file and navigate to “rails_apps” -> “myapp” -> “app” ->  “views” -> “say.” Make a new file here called “hello.html.erb” that contains the following text:
           <title>Hello, World!</title>
           <p>Hello, World!</p>
  18. Back in the “Rails Applications” window, check the box next to your app, and click “Start with Mongrel.”
  19. Your app is now running, but how to view it? Click “Configure Startup Mode” to find the address to put into your browser. Mine is Put that address in to get the standard “Welcome Aboard” page. Append to it the name of your controller and view to see your app in action:
  20. That’s it! You’ve got InstantRails working, and it’s time to actually learn RoR now. At least, that’s my plan!

Tags: ,


Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2008-2018 Betsy's Eclection All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.