Rails 3.1 Released

In case you haven’t heard the news, Rails 3.1 was released today. Lots of incremental improvements, including built-in SASS support, JQuery as the default JavaScript library, the “asset pipeline,” etc.

Git Giggle

Many thanks to Jonathan Quigg for pointing me towards Git Giggle, a UI tool that allows you to visually explore how a file in your Git repository has changed over time. Forget “git blame,” this tool is much more informative.

MySQL and Rails 3 on a PC

Rails 3.0 is the new big thing, and deservedly so. But getting MySQL working with Rails 3 on a PC can be problematic. Here’s some easy steps to make your life a whole lot easier if you’re doing Rails and MySQL development on a PC (although most of the instructions, except for the obvious PC-isms, can apply to Mac or Linux systems, too).

First, let’s go over some background technical issues.

Rails 3 works with both Ruby 1.8.7 and Ruby 1.9.2. When it comes to the PC environment, working with Ruby 1.8.7 is still a little more reliable than 1.9.2, so our installation procedure will focus on Ruby 1.8.7.

Traditionally, Rails applications have used the mysql gem to work with MySQL databases. However, this gem hasn’t been updated since 2009, and the ActiveRecord component of Rails, which is responsible for object-relational database mapping, has changed dramatically. Accordingly, the new mysql2 gem is recommended instead.

The mysql2 gem requires some native extensions, so you’ll need the DevKit or the gem can’t be built properly.

I’ve found the easiest way to get all of the components that I want on my PC, e.g. — Ruby, DevKit, etc., is to download RailsInstaller.

So, let’s get started:

  1. Install RailsInstaller: The RailsInstaller package comes with Ruby 1.8.7, Rails 3.0.7, DevKit, Git, bash and a few other niceties.
  2. Test Your PATH Environment Variable: RailsInstaller should set up your PATH properly. To test this, go to the Start menu, under Programs -> RailsInstaller, where you’ll see entries for “Command Prompt with Ruby and Rails” and “Git Bash”. The first gives you a standard PC command window (but with C:\RailsInstaller\Ruby1.8.7\setup_environment.bat automatically called to set up the environment) and the second gives you a UNIX-like window and a bunch of UNIX commands (compliments of DevKit).To view the PATH in the command window:   > echo %PATH%To view the PATH using bash:   $ echo $PATHCheck that both C:\RailsInstaller\DevKit\bin and C:\RailsInstaller\Ruby1.8.7\bin appear in the PATH. The PATH should be correct for the command window; if not, edit C:\RailsInstaller\Ruby1.8.7\setup_environment.bat as needed.If the PATH is not correct for the bash window, update the PATH environment using the Control Panel (preferred) or by creating a separate .bashrc file.To do this, bring up the Control Panel, click the System icon and then select the Advanced tab. Click the Environment Variables button, then edit the PATH in the “System variables” section to include the relevant directories.This requires the “Local Admin” privilege on your PC. If organization policy precludes this level of access, which is common with government agencies and government contractors, then set the path in C:\Documents and Settings\<username>\.bashrc. This file will conform to standard bash shell conventions.
  3. Install MySQL: Install the Community Edition of MySQL (the free one), which is currently at version 5.5. Download and install it from the MySQL site. Accept the various defaults, and make sure you agree to set it up as a service (so you don’t have to worry about starting/stopping it manually). During the install, you’ll be asked to provide a password to go with the “root” account — remember your password, please.Upon completion of the installation, ensure that MySQL’s bin directory is added to the PATH (so you can easily use tools like the mysql client program).
  4. MySQL Workbench: Strictly speaking, this isn’t required, but if you’re going to download MySQL you might as well also install the free tools that go with it. MySQL Workbench provides features that allow you to run queries against the database, design your database tables and manage your server instance (including user accounts).
  5. Create Database: Create a schema for your Rails application, along with a user account. I typically create users with MySQL Workbench, but I create schemas using the mysql client (since MySQL Workbench is terrible in this area).
  6. Install the mysql2 Gem: You’ll need to do the install manually, rather than via bundle, since there are some key parameters that need to be provided. Also, you’ll want to do the install from bash, so the various UINX-ish utilities are available to the build process.Also, a note on versions. If you’re using Ruby 1.8.7, you should be using version 0.2.7 of the gem. Those using Ruby 1.9.2 (at your own peril), should be using the latest version of the gem.To do the install:   $ gem install mysql2 -v=0.2.7 — 
         ‘–with-mysql-lib=”c:\Program Files\MySQL\MySQL Server 5.5\lib” 
         –with-mysql-include=”c:\Program Files\MySQL\MySQL Server 5.5\include”‘Note the careful use of quotes.
  7. Setup Your Rails App: Make sure your Rails app is properly configured to use the mysql2 gem. List the mysql2 gem in the application’s Gemfile with version 0.2.7. Also, in the database.yml file, the adapter should be “mysql2” and not “mysql”.
  8. Start the Rails Server: Start up your Rails application. Everything should be fine at this point. However, if the application is complaining about not finding “libmysql.dll” then go to the next step (otherwise skip it).
  9. Workaround: If your application complained about not being able to find “libmysql.dll” then you’ll need to do this workaround. Copy “libmysql.dll” from the lib directory of your MySQL installation into C:\RailsInstaller\Ruby1.8.7\bin. Then start your Rails app again and everything should be fine.

Well, the steps aren’t as painless as I’d like, but they should get you up and running with Ruby 1.8.7, Rails 3 and MySQL. Good luck!

First Batch of comments...

Wahoo! KeenerTech on Private Git

I just got the KeenerTech private git repository set up, which is important to me because, well, git is cool. Plus I really need easy branching in order to get KeenerTech converted from Rails 2.3.5 to Rails 3.0.7. The extensive site administration features have some fairly serious Rails upgrade issues.

Back from RailsConf 2011

I’m back from a very enjoyable and informative RailsConf 2011, which was held in Baltimore, MD this week. The Rails 3.1 news looks exciting, with SASS and significant new JavaScript options being added to the framework.

Scheduling Talks for a Conference

I’ve been a co-founder of two successful and profitable conferences, RubyNation and DevIgnition, now heading into their 5th an 2nd years respectively. In this time, I’ve learned a more than a little bit about running conferences. In this article, I’m going to pull aside the veil and reveal some organizer secrets for scheduling talks at conferences.

Conference speaker schedules are all about balance. According to Jim Freeze, the chief organizer of the highly successful Lone Star Ruby Conference, “There’s enough technical content at a typical conference to make people’s eyes glaze over. You’ve got to balance that with entertainment.”

Frankly, even the most hardcore techies can only take so many in-depth technical dives into the internals of the Ruby interpreter before they reach saturation point. Even more importantly, you’ll have a mix of attendees, of different technicals levels and with differing interests. A conference schedule has to provide all of the attendees with a variety of choices.

Starting with RubyNation 2010, we expanded to a grand total of 29 speaking slots (28 scheduled speakers plus a slot for Lightning Talks). This covered a two-day period with two tracks of talks, except for keynotes which were single-track. We were able to offer attendees lots of choices.

As organizers, we make a deliberate effort to balance technical content with entertainment. Deep-dive technical talks need to be spread out to avoid attendee overload, often preceded or followed by more entertaining talks, i.e. – typically a more general topic presented by a polished performer. As an example, at RubyNation 2010 an 2011, Jeff Casimir, who runs his own technical education business, functioned admirably in this role.

We’ve tried to provide a venue where attendees can see some of the community’s top Rubyists, but also where some of the local and/or lesser-known Rubyists can have a chance to shine. While we hand-pick some speakers, we also pick a lot of speakers through our Call for Papers.

There are also some topics you just have to cover, e.g. – a Ruby conference has to have at least one talk about software testing (it’s like an unwritten rule).

With 29 slots, and a dual-track format, we also feel that we can venture into territories that might be a little off the beaten path for other Ruby conferences. Primarily, this is because we feel there are tangential topics to Ruby that might reasonably be of interest to attendees, such as agile development techniques, tools like JQuery, new technologies like NoSQL databases, etc.

As Neil Ford once said, we are not just Ruby developers, we are polyglotdevelopers. The typical Ruby developer has to be conversant in a number of technologies in order to be truly effective.

Two recent examples of talks that were well off the beaten path are Jeff Casimir’s 2010 talk “How to Teach Anything to Anybody, Even Your Dev Team,” and my own 2011 talk, “Creating Killer Business Models.” The first was a talk on educational principles and the second was a big-picture business talk. Both were extremely well received.

Additionally, we deliberately try to combat a trend where many Ruby conferences have a significant number of overlapping speakers. It’s hard to be uniquely valuable when you share most of the same speakers as another conference, and most of them are giving the same talks.

We’ve even gone as far as arranging tracks of related talks. RubyNation 2010 had three consecutive talks on NOSQL databases. RubyNation 2011 had a track of JavaScript-related talks.

How did this all pay off for us? RubyNation 2010 was our most highly-rated conference ever…until RubyNation 2011 came along and was even higher-rated. Our strategies have grown RubyNation from a 135 attendees in 2008 to 216 attendees in 2011.

Rails and the PC Convergence

Rails and Rails-related tools need to work on the PC. Due to a variety of circumstances, I have ended up functioning as a multi-OS developer, and I’m often appalled at the disregard accorded to PC-based Rails development. I will explain why I think it’s not just important that the Rails community support the PC, I think it’s vital.

Compared to most Rails developers, I’m in a unique situation. I develop on a Mac for my side activities, such as supporting the RubyNation Conference which I co-founded. But I live in the Washington DC metropolitan area, and I work for a large government contractor. I’m doing Ruby on Rails development using a full-on agile methodology for a government project. But we’re mandated to do all of our development work on PC’s.

That’s not negotiable. It’s not going to change.

Jumping the Chasm

What’s happening now is that a lot of large, conservative organizations are hearing about Rails, and agile development and the benefits that can ensue from them. This includes government agencies.

There’s a phrase for this. It’s called “jumping the chasm.” It means that Rails is starting to be seen as a viable technology by mainstream organizations.

Why is this important?

Well, there are a LOT more projects in the mainstream that there are in the edges where Rails has traditionally been operating. So, we all know you can use Rails effectively to create green field applications. But now Rails is being picked for larger enterprise projects by larger, well-established and more conservative companies.

Let me be blunt. These larger and more conservative companies may not be as nimble as your typical green field Internet startup…but they have money. They have a LOT of money. And they often need many more developers for their large enterprise apps than startups do.

They’re important if Ruby is going to continue its expansion. Slamming the door in their face and saying that Rails won’t support Windows, or that it’s perfectly acceptable for a gem to not function properly under Windows is self-defeating.

Truthfully, most of these companies are fine with deploying to Linux production environments. But they’ll still prefer PC’s for development boxes.

The New Rails Newbies

On another tack, where do you think new Rails developers are going to come from?

According the famed Rubyist Dr. Nic in his keynote for RubyNation 2011, there is a parallel progression for Ruby/Rails experts. As they go from Beginner to Intermediate to Expert, they also tend to progress from the PC to the Mac. Over time, this has resulted in a much lower level of support for the PC realm, since most Experts, by virtue of progressing to Expert level, have left that environment.

Increasingly however, new Rails developers are coming from the PC realm. If their first exposure to Rails is the obsolete InstantRails package, how likely are they to be stopped in their tracks? The expansion of our community, for which many of us depend on for our revenue, requires new blood.

We need these newbies. We should provide better support for them.

Summary

Let me sum up why I think the PC market is important to the Rails community:

  1. Rails will be increasingly adopted by large, conservative organizations, including government agencies, that are more comfortable with PC’s. If you want to play with them, then you’re going to have to play in the sandbox they’re comfortable with, the PC.
  2. New Rails developers will increasingly come from the ranks of PC-based developers. Not all of these developers will have the latitude to adopt Macs as their platform of choice.
  3. Other technologies like Java, Python and PHP work effectively in all environments. If Ruby and Rails are going to compete effectively with these technologies, they need to operate on PCs as well.

Since I am now a multi-OS Ruby developer, I will be producing a series of blog entries over the next few months to help PC-based Rubyists work with Ruby and Rails. Keep checking back for new blog entries.

Good XML Schema Validator

The online XML Schema Validator from DecisionSoft has been excellent for validating XML files against an XML schema. Unlike most parsers, it also provides extremely useful error messages, which helps greatly in debugging.

Update: (2012/03/30) The company name and URL changed, so I have fixed the link.