Skip to content

Instantly share code, notes, and snippets.

@kalleth
Created September 12, 2011 11:51
Show Gist options
  • Select an option

  • Save kalleth/1211092 to your computer and use it in GitHub Desktop.

Select an option

Save kalleth/1211092 to your computer and use it in GitHub Desktop.
class Foo < ActiveRecord::Base
after_initialize :do_stuff
def do_stuff
self.parameter = "string" if self.parameter.nil?
end
end
>> f = Foo.nil
>> f.parameter
> nil
>> f.do_stuff
>> f.parameter
> "string"
rails 2.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment