Skip to content

Instantly share code, notes, and snippets.

@denysonique
Forked from mnaser/my_model.rb
Created July 1, 2011 17:14
Show Gist options
  • Save denysonique/1058985 to your computer and use it in GitHub Desktop.
Save denysonique/1058985 to your computer and use it in GitHub Desktop.
Is there a cleaner/simpler way of doing this?
class MyModel < ActiveRecord::Base
after_initialize :setup_defaults
attr_accessor :foo_bar
def setup_defaults
@foo_bar ||= "my default value"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment