Created
February 2, 2011 14:20
-
-
Save nicolasblanco/807725 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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