Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
Created April 8, 2011 12:14
Show Gist options
  • Save ericsaboia/909718 to your computer and use it in GitHub Desktop.
Save ericsaboia/909718 to your computer and use it in GitHub Desktop.
module ActiveRecord
class Base
def self.build
instance = self.new
self.column_names.grep(/_id/).each { |coluna|
coluna.match(/(.*)_id$/)
instance.send($1+"=", $1.camelize.constantize.new)
}
instance
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment