attr_symbol

Allows certain attributes in ActiveRecord models to be handled as symbols. These attributes are stored in string columns in the underlying data store.

Usage

class Thing < ActiveRecord::Base
  attr_symbol :a
end

# Stores the string 'foo' in the field 'a'
thing = Thing.create!(:a => :foo)

thing = Thing.find(1)
thing.a  ### Returns :foo

thing.a = 'urk'
thing.a  ### Returns :urk

If any of the attributes passed to #attr_symbol are not database columns of type string, an ArgumentError exception will be raised.

Copyright © 2011 Justin Wienckowski. See LICENSE for details.