Daniel Azuma
Articles with tag "rails"...
Rails/ActiveRecord 2.1 and TEXT/BLOB fields
Posted on Fri, Jun 27, 2008, at 04:52 PM (0 comments)
Tags: rails

We just ran into a rather annoying gotcha when upgrading our application from Rails 2.0.2 to 2.1. All of a sudden, a few the columns in a few of our ActiveRecord classes unexpectedly started defaulting to nil, and refusing to save with a MySQL error. We tracked this down to a change in how ActiveRecord 2.1 is handling default values for BLOB and TEXT columns in a MySQL database.

Background

ActiveRecord uses the database schema to automatically “construct” classes and populate default values. For the most part, this works great. You can create a table such as:

  CREATE TABLE `first_objects` (
    `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
    `number_field` INT NOT NULL,
    `string_field` VARCHAR(100) NOT NULL DEFAULT 'hello',
    PRIMARY KEY  (`id`)

HTML comments and Rails views
Posted on Sat, Jan 05, 2008, at 01:25 PM (0 comments)

Comment your code—it’s a mantra they drill into you in Programming 101. I know, most of us took that class at age 5 or 6, but it’s still important 30 years later.

Of course, in those bygone days, we were probably programming in C (or maybe Java for you young’uns, or FORTRAN for the graybeards). Comments were there for your benefit as a programmer, and the compiler helpfully threw them away when building binaries for end-user consumption. You could put anything you wanted into your comments and not worry about them becoming public knowledge. Anything, including:

C XOR WITH 42405 TO ENCRYPT MY SECRET VALUE

or

/* This paranoid and performance-killing logic is here because
   the customer is a clueless f***ing anal-rententive nutcase. */

or

// I have a...
The Rails Rdoc Template
Posted on Sat, Dec 08, 2007, at 10:26 PM (1 comment)
Tags: rails, ruby

It’s amazing what you find if you just bother to look.

I was updating Zoodango’s internal rdocs, and I got thinking, the layout that rdoc generates by default is not how I’d do it. I often have fairly long lists of files, classes, modules, and methods, and the three scrolling lists across the top are too small to scroll effectively. Just try scrolling through the class list on the Ruby core library rdocs and you’ll see what I mean.

Most people’s screens and browser windows are horizontal, so I couldn’t understand why the template would take up valuable vertical real estate in that way. The rdocs for Rails look much better—moving the scrolling lists to the left side. Not to mention that the formatting looks quite a bit…

Blog reboot
Posted on Tue, Dec 04, 2007, at 10:29 PM (0 comments)

In the best tradition of “geeks love to build it themselves”, I’ve decided to move my technical blog here to my home page, now running on the Rails 2.0 release candidate. It’s using the same Rails-based blogging engine we developed for Zoodango 2.0. (Though I haven’t hooked up the tags and Atom feeds to my controller yet—I’ll get to that shortly.) Best way to alpha-test our software is to use it ourselves, I suppose.

We pretty much gutted our code base for Zoodango 2.0 and did a lot of rearchitecting based on our experience writing the first incarnation. As I have time, I’ll try to share a little about what we’ve learned from the past two years of working with Rails. Maybe, if Bill and James agree, we’ll also open-source a…

Recent
Tags
Random blogs