Skip to content

Instantly share code, notes, and snippets.

@nicolasblanco
Created February 2, 2011 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nicolasblanco/807725 to your computer and use it in GitHub Desktop.
Save nicolasblanco/807725 to your computer and use it in GitHub Desktop.
class User < ActiveRecord::Base
serialize :preferences, Array
end
user = User.new
user.preferences # => nil
class User < ActiveRecord::Base
serialize :preferences, Array, :default => lambda { Array.new }
# this would be the same as :
# def after_initialize
# self.preferences ||= []
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment