Saturday, November 10, 2007

Nested ActiveRecord Relationships and Validation Conundrum

I ran into a bit of a pickle earlier this week with some models and their relationships.

The Situation

* A partner has an account.

* An account has an address.

* Accounts do not require an address; it's optional.

* Partners do require an address.

The Problem

So how do I enforce the presence of an address for the account assigned to the partner?

My First Attempt

My first thought was to break the encapsulation and create a direct partner-to-address relationship. Then I came up with the clever hack of keeping the partner-address in sync with the account-address during assignment, so when you set the address for the partner, it would automatically set the account to the same address. But it just didn't sit right with me; it wasn't the typical Ruby on Rails elegance I had come to expect. So I reached out to my partner in crime (Jack Danger) and asked for his opinion.

A More Elegant Idea

Jack suggested a more elegant simplification of just validating the presence of the address from the partner level like so:
validates_presence_of :address

def address
account && account.address
end
Now that's the simplicity and elegance I've come to expect from a Ruby on Rails application.

A Possible Third

But Jack also took it a step further and suggested subclassing account and making address required, so we'd have two types of accounts, one with optional addresses and one with required addresses. That might be even less code and arguably more elegant, but my gut just tells me it's a little less of a hack than my original attempt and not quite as pure as his first suggestion.

Wrapping Up

I went with Jack's first suggestion and I'm satisfied with the results, but I'm curious to hear if anybody else has tackled the same, or similar, problem, and how they solved it.

Saturday, October 20, 2007

The future is green

No, I'm not talking about switching from my fossil fuel burning automobile to a hydrogen powered motorcycle. At least not yet. I am talking about pickles. adPickles. adPickles has started the design of its B2B platform. Things are looking pretty interesting right now. More adPickles info to come...

Thursday, September 13, 2007

adPickles and Rails - A beautiful marriage!

Using Rails to develop the adPickles web site was a smart choice. It seems that some of the brightest and best talent in the business has adopted Rails as a tool in their arsenal. And some of those brightest, I am proud to say, are the folks who are putting this project together. Another smart technical choice... png vs. jpg gave us freedom to expand our design horizons. Rails and adPickles. A great marriage indeed.

Thursday, July 19, 2007

The Midas Touch

Stewart Padveen has the Midas Touch when it comes to web companies. I've spent the last twelve years of my career designing and deploying the technologies that drove two of his companies (HotOffice and Nutrio). While I was busy doing that, he started two more successful ventures (MotionPoint and Firmagen). He pitched his latest idea to me at the beginning of this year and it sounded like another winner; I knew I had to be involved.

Although I've cut my teeth on Java and "the enterprise", a couple years back I started dabbling in a little gem (if you'll excuse the pun) called Ruby; a spectacularly elegant programming language. Then some crazy ambitious young Dane came along and built on top of it an even more wonderful web framework named Rails. It was a match made in Heaven and I fell in love immediately.

And speaking of perfect matches, AdPickles and Ruby on Rails make a very cute couple. The project has made tremendous progress thanks to this framework and the tight-knit community of brilliant supporters and contributors, and most of all Jack Danger Canty, their dedicated wizard. Not since the Perl years of yore have I seen such blur of productivity.

But the back-end isn't where all the magic happens. There's a client piece to this puzzle as well. I won't spill too many beans here, lest Stewart chastise me, but let me say that Windows is a cruel mistress, and the impressive skills of Aaron Cody have managed to tame that shrew.

Mark my words, and bookmark this feed, this is going to be another rocket ride to the stars.

Tuesday, July 10, 2007

Our true colors

While the technical development of the adPickles technology is an intense but highly enjoyable project, we have paralleled our efforts with another project that is far less technical but a lot more difficult than I had ever imagined; picking the adPickles web site colors and web page design and layout. Color and design preferences are purely subjective, therefore it is no surprise that 12 people have 12 different opinions. Trying to find that universal design and color scheme that touches a universal emotionality is the holy grail of design. Simplicity is key for sure, but so it functionality and about a thousand tiny nuances that can inadvertently make or break the project. After countless hours or mock ups, designs and layouts by Sari, our resident "web-Rembrandt," we have settled on our colors and design. I am happy to report that the response has been unanimously positive from all who have seen it. I am sure we will make changes to the adPickles web site as we forge ahead, but thanks for a wonderful effort by Sari (with a little help firm tech gurus Ted and Jack).

Saturday, June 30, 2007

Welcome!

Welcome to our blog! As we gear up to launch the adPickles website, this blog will enable us to share our thoughts with you on why we started adPickles and what we're hoping to accomplish.