Rails 3.2 and Active Record Store

What exactly is Active Record Store and how to use it with Rails 3.2

Rails 3.2 was released earlier today and it provides a variety of new features including: Active Reload, Faster Dev Mode, Tagged Logger and, of coarse, Active Record Store. When Active Record store was released I was a bit curious as to how it works since I only saw the same example on every blog out there and the example itself just wasn’t doing it for me. Therefore this article will briefly explain how to use Active Record Store and how the contents of are stored in the database.

Last Updated

This article was first published on January 20th 2012 and was last updated on January 20th 2012.

Active Record Store

Active Record Store is used for storing additional attributes within a database record without the need to have to create additional attributes (columns in the database table) to store these values. The contents of these “additional attributes” are stored within the scope of an existing attribute and as serialized as a JSON object. Once fetched, they’re unserialized and used as regular attributes. Here’s the basic code for using Active Record Store:

Loading…

Active Record Store is a great idea for when you need to store optional data into a database record. One thing to keep in mind, however, is this does go against the 1st rule of normalization. This database storage method also makes database searching of the record unpractical when a search is issued on the storage column.

More about Rails 3.2

Some of the other things I noticed about 3.2 was that the development mode is alot faster. Rails startup and migration creation are much faster. Routes also load and parse faster. Other features such as Explain Queries, Compression of Page Cached Files and Tagged Logging are among the many new features provided by rails.

Some Street Cred

Here are some more links to follow up on Rails 3.2

Add Your Comment