About This Blog

Musings, reports, and notes to ourselves about technical matters of importance.

Blog Posts

Extending Date/Time Formats in Rails 3

One of the many under-the-hood changes in Rails 3.x involves how date and time formats are extended. This is still done in an initializer, but the Rails classes have changed.

Here’s how it was done in Rails 2.x (for example):

# Rails 2.x
# /config/initializers/date_formats.rb
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!(
  :teg_compact => "%m/%d/%Y %H:%M", 
  :teg_long => "%d %B %Y - %H:%M", 
  :teg_date => "%m/%d/%Y", 
  :teg_label => "%d%B%Y-%H%M"
)

And here’s how it’s done in Rails 3.x:

...Read more

RSpec Request Specs vs Cucumber

Cucumber has major mind-share these days. Rails 3 in Action and The RSpec Book illustrate how behavior-driven development can be done alternating between integration/acceptance tests and unit tests via Cucumber and Rspec.

Not everyone is such a fan of Cucumber, though. Ryan Bates favors using RSpec request specs instead, and DHH thinks that Cucumber and even RSpec are spurious.

After struggling with Cucumber for a while, we agree with the latter view. The main problem with Cucumber is that its attempt to provide a near-natural language DSL (Gherkin) for integration testing is too clever by half. Gherkin is thoroughly brittle in that can only parse statements defined in step definitions, which in turn make Ruby calls using Capybara (or Webrat). Any breaking test leaves you scratching your head wondering whether it is due to a problem with the Gherkin, the step definition, or the underlying code.

...Read more

Rails 3.1 Dev Setup

Now that Rails 3.1 is nearing release, we’ve finally decided to migrate from 2.x development into the sunshine of the new Rails 3 world. We’re less embarrassed to be such late adopters than perhaps we should be, since at last year’s Golden Gate Ruby Conference at least half the people we talked with hadn’t yet started to move to Rails 3. But the time finally now seems right.

References and Resources

Beyond the infinite sources of tips and explanations about Rails 3 that Google reveals, here are some references that we’ve found to be particularly useful:

What is missing right now is an updated version of Deploying Rails Applications, since the old nginx-mongrels stack has fallen out of favor (and indeed mongrel doesn’t appear to work at all with the new rack-based middleware in Rails 3).

...Read more

New Web Site

At long last, a break in other more pressing projects has allowed us to update this web site, replacing the older one based on OpenACS with a true “eat your own dog food” Ruby on Rails site.

Some things did not survive the transition — notably some of the demos (the Seattle Angina Questionnaire and Q-Assessor) and nearly all of the commentaries. Those of you who recall (or check Google’s cache while it lasts) will know that those commentaries tended to be quite political in nature. We haven’t substantively changed our views on things; we’ve just decided not to be so public about them.

Instead, what posts will occur in this space will focus on technical issues. The process of moving to Rails has provided many topics worthy of comment, though most have been covered before and more definitively elsewhere. Some thoughts may show up here anyway.

...Read more

RAID1 on Debian Sarge Redux - SATA drives and 2.6.x kernel

In an earlier discussion, we described how to install RAID1 on a by-now older Debian Sarge box using a 2.4.x kernel and IDE drives. While the basic approach remains similar, we ran into issues installing on a new “9G” Dell box (SC440) which has SATA drives and the Intel ICH7 controller. Here is a step-by-step summary of how we got this to work.

The discussions by “philcore:http://www.debian-administration.org/users/philcore "here”:http://www.debian-administration.org/articles/238 and here (along with reader comments) are probably the most useful information, and ultimately helped guide this approach. Lots of other discussions can be found by Googling on various combinations of “raid1”, “sata”, “sarge”, “grub”, “initrd”, etc — but most of those discussions are somewhat out-of-date.

NB: supposedly the current Sarge installer can create RAIDs for you, but this was not at all apparent to me, and when I tried to use the installer tool to “configure RAID” with a half-completed install, it blew up most spectacularly. This doesn’t seem ready for prime-time yet.

So here’s one approach that worked on this particular box.

...Read more

RAID1 on Debian Sarge

A RAID device is a Redundant Array of Independent Disks. The concept was developed in 1987 at UC Berkeley and involves the creation of a virtual disk from multiple small disks in order to deliver improved performance and reliability. There are many flavors of RAID and lots of variations in how to implement it. We detail here a specific instance we use: software RAID1 using IDE disks on a Dell PowerEdge box running Debian “sarge” loaded with grub, managed by mdadm, using the ext3 journaling file system.

Overview

First, a list of references. None of these use exactly the combination of choices we use, but they provide all the pieces of information that are necessary:

  • The basic Software RAID HOWTO at the Linux Documentation Project. This provides general background information about the concepts and tools.
  • Philip McMahon’s guide to using the bootloader grub, which Debian now uses by default instead of lilo. Philip provides more explicit instructions about how to handle multiple partitions, but he doesn’t use mdadm. Instead, he uses the older configuration management tool raidtools.
  • A detailed document usr/share/doc/mdadm/rootraiddoc.97.html installed with the mdadm package. These instructions rely mostly on lilo but do have some comments about grub albeit in the context of using initrd as part of the boot process, which the latest sarge install doesn’t do. Nevertheless, these instructions are primarily what we use here.
  • This brief comment highlights installing grub on the second disk and makes clear how to generate a mdadm config file in /etc/mdadm.

So here is the process to convert an existing (or new) Debian box to software RAID1:

...Read more