(This guide was initially supposed to be an internal syndeo::media document which I would pass around to the new people joining our team, but as I wasn’t really discussing anything confidential, I figured there was no harm in publishing this on the blog. There are lots of Rails tutorials already out there, but this one explains some fairly specific additional steps, including getting MySQL and subversion running on your Windows developer machine. The main focus of this guide is to get designers up-to-speed as quickly as possible, and as such, it glosses over a lot of the technical information that guides like these ordinarily contain.)
Before we get started, it’s important to have a basic understanding of exactly what it is that you’re installing on your Windows box.
Ruby is a scripting language which can be used for many things, although its most common use by far is web programming. When we say we’re installing Ruby, we are actually more precisely installing a Ruby interpreter. An interpreter is a little program that accepts code written in the Ruby language and actually makes it do, you know, stuff. It’s important to note that the interpreter only gets loaded into memory when it’s needed, and then get’s killed right after it’s done doing its thing. (In this manner, it’s different from servers like Apache or MySQL, which hang around in memory waiting for requests to come in.)
Ruby also has a fairly robust plug-in management system called RubyGems. Plug-ins are exactly what they sound like, they’re additional bits of code that you can “plug in” to the Ruby interpreter to make it do other cool stuff. You will use this A LOT with syndeo::media applications, as it’s simply more efficient to download and then modify a given piece of code than to try to write one from scratch yourself.
Rails is a framework built using Ruby (hence the full name “Ruby on Rails”). What does Rails actually do? It simplifies a lot of the most common, nitty-gritty aspects of web application development by introducing a boatload of tools and methods into the mix. It also enforces a fairly strict file structure, so that each team member isn’t tempted to do things their own way. (Rails is very big on following “conventions.”) Lastly, it gives you access to a whole mess of plugins written by a fairly active community, which serves to further cut down the amount of time building foundations, and allows you to concentrate on whatever makes your project special. So when we talk about syndeo::media projects, we usually call them “Rails applications” instead of “Ruby applications” since “Rails” is the more specific name.
MySQL is a database server. A lot of people only know MySQL as that thing that stores your Wordpress blog posts, and indeed, that’s a fairly accurate description of what it does. But MySQL works in a variety of different settings, and as such, this is often the server used for Rails applications as well.
For non-programmers, databases can be particularly difficult to visualize, as they often don’t have a graphical component that you can look at and click on. We call MySQL a database server because, as mentioned above, it sits around waiting for someone to make a request and then serves data as needed. Who is this “someone”? In some cases, it will be the Ruby interpreter enacting a command written by a developer. In others, it’ll be an actual user typing commands in to the MySQL console. The language we use for these commands is called SQL (alternately pronounced “sequel” and “ess-cue-ell“), and it’s very much like standard English. It’s fairly easy to guess what a SQL query like “SELECT birthday FROM users WHERE username=’luis’” does (it retrieves the birthday of the user named “luis”).
The good news is that Rails doesn’t really require a deep knowledge of SQL, because a lot of that stuff has been encapsulated in a pretty powerful command called “find”. If you wanted to find all the users in your current database for example, you would say something like:
User.find(:all)
If you wanted to grab the data of user “luis,” you would say:
User.find(:first, :conditions => “username=’luis’”)
Now, at first glance, that doesn’t look particularly less complicated than the traditional SQL version, but it actually is, and very much so. We’ll go into slightly more detail on retrieving data when we’ve actually got a Rails application running, and you’ll see what I mean.
subversion is a version-control system. The average person will usually have no idea what that means, but for anyone who is internet-aware, the best example of a version-control system in action is none other than wikipedia. “Version-control” is essentially just keeping track of all the various versions of a particular file, and archiving them in a linear fashion. So when you say you’re at revision 0, you’re currently at the very first version of your code (usually a couple of empty files that don’t do anything). If you check the History tab on any Wikipedia article page you’ll see a nice list detailing the various changes made to the current article over time. Version-control, and svn in particular, helps teams by making sure that nothing that they write is ever lost, and allows you to work simultaneously without worrying that someone is going to overwrite your work by mistake.
There are two key components to any version-control system: the server and the client. In the case of syndeo::media, we’ve already got an svn server running, so all you have to do is download the client software which will allow you to access the server.
=======
Now, since this is still just the introductory essay, we may as well get some work done and start downloading the various items we’ll need to get started.
Ruby, RubyGems, and a book(!) : http://rubyforge.org/projects/rubyinstaller/
MySQL: http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-essential-5.0.27-win32.msi/from/pick
Tortoise, a super-cool subversion client: http://tortoisesvn.net/downloads
RMagick: http://rubyforge.org/frs/?group_id=12&release_id=8170
(Scroll to the bottom to find the Windows — or W32 — installer. I’m skipping ahead a little here and actually asking you to download a Rails plug-in. This is because the RMagick installation process on Windows is a painful exercise, so I figured we might as well get an early start on that.)
You’ll notice that Rails itself is missing from this list. That’s because we’re going to be installing Rails via the Gems system, which means we will not be downloading anything directly. That said, you can grab a standalone gem from this page, if you are so inclined: http://rubyforge.org/frs/?group_id=307)
Quick links to other articles in this series:
PART ONE: Introduction to Ruby, Rails, MySQL and Subversion.
PART TWO: Ruby Installation and Language Primer.
PART THREE: Rails, MySQL and the Windows Command Prompt.
PART FOUR: RMagick and Subversion.