Archive for the ‘rails’ category

Fun with Rails Constantize

December 1, 2007

Visualization DiagramHave you ever found yourself working on a Rails project where you need certain behavior in a model based on type but STI[1] is not the right fit or you are already using STI and can not subtype again? I was working on a problem where a model utilized STI to create two types: Icon and Color. Within each type I had different data. Some of the data represented defaults for Icons or defaults for Colors and the others were specific. I’ve put together a little diagram on the right to illustrate this[2].

The way we had modeled the data made it very easy to pick out the specific icon or color theme (using an ActiveRecord finder for that type). However, based on the data instance returned by find I wanted to execute a series of methods to populate other models with data relevant to the Icon or Color instance. (more…)


Sexy Time Zones in Ruby on Rails with Timezone_Fu

November 23, 2007

As easy as has_timezone :fields => [ :start_datetime, :end_datetime].

Working with Timezones in Rails even after you have installed the TZInfo plugin is still a pain in the you know what. (You are using TZInfo, right?) World TimezonesI never liked having to jump through hoops converting from UTC to localtime when displaying times to Users. I suppose I could have used Javascript to do the conversion but I prefer to deal with the conversion on the back end.

Adding support for time zones to our apps wasn’t very fun. While adding timezones to another model model for the third or forth time I decided there had to be a better way. I pointed my browser to the agile web development plug in site and did a quick search. I found a couple plug-ins that helped with timezones or helped with date time pickers; but nothing that did quite what I wanted. (more…)

Zero to Riding the Rails in Four Months

October 14, 2007

rails-podcast.pngWhew! four months of nose-to-the-keyboard development work, and we launched our new product! Because it was the first time we designed, developed, and deployed a complete web application with our new team, we wanted to chronicle our experiences over the whole process – particularly with Ruby on Rails. We thought doing so would help us improve on our experiences in the future. And we hope it can help you too…

In the beginning there was Java and it was good, but something was missing. Java as a partner was not particularly pretty, it was not very fun to wake up to in the morning, but it got the job done. In late May Daniel sent an IM to Matt, He was having problems with eclipse and svn and went off on a tangent. The IM went something like this:

Daniel: “I see why the RoR people are in love. Not that SVN has anything to do with RoR”
Matt: “RoR?”
Daniel: “Ruby on Rails, I was playing with it yesterday”
Matt: “I see, is it good for backend? frontend? both?”
Daniel: “If you are ok with going with the defaults it lets you focus only on developing features, so you don’t have to worry about backend or frontend. Some of the deployment tools are pretty neat too. Ok, back to topic…”

Daniel had just watched the Rails Screencasts and was in love. The concerns we were having with Java and Google Web Toolkit seemed like they would probably go away with Rails. It took a long time to develop new features the way we had been doing things. After debating the topic for a while we had a founder’s meeting in the car while driving to Target, and decided: we would devote two weeks to try our hand at porting (rewriting) YouBook from Java to Ruby on Rails. We quickly purchased the PDF+Hard Copies of “Programming Ruby” and “Agile Web Development with Rails” from Pragmatic Programmers, and the adventure began.