Rails 1.1: Loaded with 37s extractions 28 Mar 2006
23 comments Latest by Rugby Fan Steve
Rails 1.1 is alive. It's a huge update, the biggest yet, with more than 500 fixes, tweaks, and features from over 100 contributors. It's also a triumph of extractions. Most of the blockbuster features started life in 37signals applications. A rundown:
- Polymorphic associations/join models: Sunrise gave birth to both of these features as I needed to implement rich tagging against multiple classes (you can tag people, companies, entries, etc with the same tags). This an example of us sharing new features even before the founding application has launched.
- Accept-driven responses: The new Basecamp API is based upon the work I did when discovering usefulness of the accept header in HTTP and working with Jamis to built a great way to encapsulate that. Now we can have the same code easily serve Ajax-calls, API-calls, mobile clients, and more.
- ActiveRecord::Base.to_xml: When creating APIs, you usually have to expose tons of model objects as XML (like give me all the todo items for this list in XML). Marking all this XML up by hand every time is tedious. We needed something better to stay productive for the Basecamp API, so to_xml was born.
- Integration testing: Testing Campfire properly required more than Rails initially provided. How do you verify that things are working right when two or three people are chatting simultaneously? With integration testing that's easy as you can run concurrent sessions and make assertions about the interactions. Jamis extracted this from Campfire and did a great job writing about how to use it.
- Enumerable#group_by and Array#in_groups_of: How to easily partition data into chunks for presentation? These two methods were born from Campfire's transcript browser by Marcel and Sam.
- form_for, form_remote_for, and fields_for: Most of the form helpers in Rails was based around the notion that you would only have 1 form per object type per page. Sunrise quickly brought that to same with many forms for similar object types all over the place. So we extracted a new, cleaner way to specify forms and their relationship to models.
Frameworks are extractions. The best ideas arise when you're squeezed between the constraints of time, reality, and a desire to be happy writing beautiful code. There was no way we could have come up with all of these new features by simply contemplating what some people might need some day.
Designing software by guessing about the future is a terrible way to arrive at something pleasant.