Created
June 16, 2011 09:55
-
-
Save jrom/1028970 to your computer and use it in GitHub Desktop.
Hack to create a new skinny model from an existing one
This file contains hidden or 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
# By James Urquhart (jamesu) | |
class ActiveRecord::Base | |
def self.thin_model | |
table = table_name | |
@@thin_model ||= Class.new(superclass).tap do |anon| | |
anon.class_eval { set_table_name table } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment