Created
July 13, 2009 05:11
-
-
Save akia/145944 to your computer and use it in GitHub Desktop.
[Rails] table prefix
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
[railsserver@anhnt models]$ console | |
Loading development environment (Rails 2.3.1) | |
>> User.table_name | |
=> "tblusers" | |
>> |
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
class PrefixModel < ActiveRecord::Base | |
self.abstract_class = true | |
#establish_connection "newdb_#{RAILS_ENV}" | |
def self.table_name_prefix | |
# Code to hand out the appropriate prefix at the appropriate time. | |
"tbl" | |
end | |
end |
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
class User < PrefixModel | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment