From Reading Spree

Having worked with the Spree gem earlier this year, I was curious to see how things had progressed with my favorite e-commerce store.

The look of the site itself spreecommerce.com has much improved. I’m glad to know that Sean took my suggestion for the name. It really rings well. I’m also happy to see my website amongst those listed in the ‘Featured’ category, although it was a major team effort.

Anyway, getting on to today’s discovery, I was reading through the source code of the various vendor/plugins, hoping to learn or discover a few cool things. Boy, I wasn’t dissappointed!

First off, the awesomenestedset gem. It’s a simple enough concept, to which you can find explained with nice graphics at developer.com. I had read about that data structure before, and reading that article, it became obvious that using this technique for a navigation structure makes all the sense in the world.

Secondly, a minor but fairly important point I did not know about sqlite. It is possible to establish a database entirely in memory. For small datasets, especially those that resolve around test, this is an incredibly valuable technique to speed up an application or testing.

Third, I came upon this declaration, or similar forms a couple of time through different gems.

class_inheritable_accessor :calculators

Fourth, the unloadable keyword, which is probably not something the average developer will need on a day-to-day basis, but which helps to make constant unloadable (not dependent on refreshing the server).

I recommend to anyone interested in Rails to read more about this from raulparolari.com. He explains very clearly this topic. In short, a class inheritable accessor is similar to an class instance variable, whose major difference is that its default value is given to inheriting children.

Reading through the Spree source code is absolutely fantastic exercise for anyone who wants to be a better Rails programmer. There are plenty of highly qualified people who have brought their insights into this project. Unlike Rails itself, it is possible to read all of the code in one day.

From learning how to pack a gem, to using jeweler for your application, test structure with shoulda and rspec, jazz up your application with DHTML with Prototype (script.aculo.us) and jQuery, SASS and compass. It’s all there for the intermediate Rails developer. On top of it all, you get to be part of one of Rails’ fastest growing project!

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.