Posted on 30-04-2008
Filed Under (Code) by Cody

When we launched Fan Profile just over a week ago, we knew there would be bugs, refactoring and tuning.

There always is.

Minus the bugs, I love this phase. The pressure to launch is gone, and my attention turns to making the product perfect. I mean, who doesn't like perfection?

This time, my pursuit took me and the entire team into huge pile of CRUD.

I had just finished reading the "Gospel of the Seven Actions" (new, show, index, edit, update, create, destroy), and just that easily, I became a born again CRUDian.

My plan was to go through all our controllers and simultaneously tune queries, move code to models and "CRUDify" manufactured actions such as "search, about, mail, send_group_invite" and more.

I figured I could do it incrementally and quickly, so there was no need for a branch -- I'd be done in a day, day and a half.

Whoooopsss.

Yeah, I'll branch in the future because this was no easy task.

Some actions just don't fit nicely into one of the seven. For example, what about an action that takes a comma separated list of positions and rearranges a user's favorite teams based on those parameters?

Well, I had called it "reorder," but delving into the Gospel, I found out that what I am in fact doing is updating an existing order, so we get:

 
map.resources :users as 'fans' do |users|
  users.resource :team_orders, :controller => :user_team_orders
end
 

Notice it is resource not resources. This means that a team can have ONE order, so you can specify the update action without specifying an id, which is good because there is no "order" model anywhere that maps to a table.

In the case of groups, we actually split one controller into eight, but the task is winding down.

I'm fixing the tests and caching and then I'll QA, hopefully in time for a release Monday. Then Fan Profiles will be one giant piece of CRUD where all exposed actions will be "one of the seven" (cue the choir).

If I didn't have a financial accounting mid term on Sunday, I'd celebrate our walk into the CRUDdy light.

(0) Comments    Read More