May 26, 2010 – Last night I attended my first ever Ruby users group meeting. It’s a meeting of the RubyHam Yahoo group for us folks here in Birmingham, Alabama. There were about 15 people there, and four short presentations on various Ruby and Rails topics, most of which were over my head at this point in my Ruby walk.
I began my study of Ruby and the Ruby on Rails framework in early April 2010. With my long FoxPro background (1992) and some .Net (2008), I’ve pretty much been a Microsoft man for a long time, so I’m not really sure what drew me to study Ruby and the Rails framework in the first place. I guess I’m just an easy sell on coding tools that sound cool. I knew the basics of the MVC pattern from my recent study of ASP.Net MVC, so I kind of knew what to expect, since Rails is an MVC framework too.
Mac, Windows, Linux? – At work I’m a Microsoft guy, but at home in the evenings I dance on the Apple floor (since about 2006) with my beautiful white iMac 20”. Since all of this was going to be new to me anyway, I decided to go the route that was the most foreign to me so I could really learn a lot of new things from this venture… So, I decided to setup that unsuspecting Mac to explore this dark new world.
Terminal Window vs. IDE…
I am an IDE guy, and not a terminal window guy, so I started out by installing the NetBeans 6.8 IDE (free, and it runs on Linux, Windows, and OSX). There are several choices when it comes to Ruby IDEs: RadRails from Aptana (free), Ruby In Steel (not free), RubyMine (not free), and many more. You can read this blog post to learn the pros and cons of some of these (and perhaps find a few more choices down in the blog comments). You’ll want to study them all to see which one you like best. Note: Ruby/Rails doesn’t require an IDE… you can do it all from the command line, but surely you’ll want a good IDE of some sort.
The Rails framework (that is: the generated app it creates) defaults to work with the SQLite database thingy, which I knew little about, other than its simple life as an embedded database, which is a cool thing for sure. But I wanted to go with a more complex stack using MySql just because it seemed like a more big-boy thing to do. So I downloaded, installed, and configured MySql (for the first time ever, since I’ve always used Microsoft SQL Server) and now some of those mysteries about MySQL are now cleared up for me as well.
Now, I’m still a relative newbie on Mac stuff that takes me to that scary Terminal window, and man, it took some work to get my machine all gem’d up and ready for Ruby / Rails / MySql development, but I somehow stumbled through it all by surfing around for instructions. I’m still not exactly sure what all those ‘sudo’ commands did, but hey, it now works.
On Max OSX, Ruby is already installed with the OS, but I still had to get the rest of the bits in place. I may have installed a few things along the way that were already in present, but it seemed to work out fine.
First Rails app…
So there I was… Ruby, RubyGems, Rails, MySql, NetBeans 6.8. Ready to rock!
NetBeans has a New Project wizard for Ruby on Rails apps, so I fired that off to create my first ever Ruby on Rails app. The Project Wizard guides you through choosing your project name and location, Ruby version, database choice, web server, and Rails version. After the project is generated, if you decide to change which databases engine you’d like to use, you just edit the database.yml config file in the projects /Configuration folder to tell it which database adapter to use.
(I later setup and tested SQLite and it was cool to get that working too. Seems like I had to install some Ruby SQLite gems in the environment to get it set up.)
So the whole install/configure thing was surrounded with several mysterious activities to get everything in the environment setup properly, but I did it. I can’t express the feeling of success I had after spending a couple of hours hacking away at my machine to install all this stuff, much of which I didn’t understand at the time.
By “success” I simply mean that I can now:
- start MySql server (I have not set it up to automatically start up yet. I don’t want it running all the time)
- launch the NetBeans IDE and create a new Ruby on Rails project
- ‘script/generate scaffold’ – code generates a model, the views, and the controller (from the IDE, mind you, not that crazy command line)
- ‘migrate’ that model schema to the database (again, from the NetBeans IDE)
- and finally, hit the Run button to watch the web server start up and take me to the default generated landing page for my app.
That wasn’t so bad..
Hearing all those smart guys talking in the room last night, I’d say I’ve got a LOT to learn from here, but I guess they all started where I am today, or even where I was back April wondering what this Ruby thing is all about.
You can do it too…
Now it’s your turn to give Rails a test drive. Configuring the environment is different on every OS platform, so depending on what OS you’re running (Mac OSX, Windows, or Linux) you’ll just have to surf around and find the instructions.
Here is a link to basic Ruby installation instructions for each OS. Then, you’ll still have to do some more work to install the Ruby on Rails framework.
Here’s is her set of instructions you can follow which guide you through installing Ruby, Ruby Gems, and Ruby on Rails.
Sadly, like many resources on the internet, the setup information is scattered all about. Many instructions assume you already know certain things about the platform. And there are different versions of everything… Ruby has a version, Rails has a versions, gems have versions. Heck, the gem installer even has versions. Oh yeah, and what is a gem in the first place? (You’ll find out soon enough once you get started.) I swear, it seems like more than you can keep straight at first. Oh, wait, but there’s RVM (Ruby Version Manager, I think). What the heck is that all about? Maybe I’ll find out if I keep digging.
Resources to help *YOU* get started
You can Google “Ruby on Rails” and get more info than you can shake a stick at, but below I’ll list out some resources that were helpful to get me started (I’ll add more to the list when I can go back and find them). There are podcasts, videos, and blogs galore.
RailsTutourial.org (Check out the online Book link at the top of the page)
http://www.sitepoint.com/books/rails2/samplechapters.php (free book chapters in PDF, including setup for each OS)
http://guides.rubyonrails.org/ (good getting started info from the mail Rails site)
http://www.ruby-forum.com/ (very active user forum)
http://railscasts.com/ (videos. very good videos!)
youtube videos (more videos)
http://5by5.tv/rubyshow ( a good podcast)
http://www.buildingwebapps.com/learningrails (audio lessons and video screencasts)
RubyFlow.com Daily Ruby/Rails links added my community members
See more resource links here: Resources for getting started with Ruby on Rails