Skip to content

Instantly share code, notes, and snippets.

@akia
Created July 13, 2009 05:11
Show Gist options
  • Save akia/145944 to your computer and use it in GitHub Desktop.
Save akia/145944 to your computer and use it in GitHub Desktop.
[Rails] table prefix
[railsserver@anhnt models]$ console
Loading development environment (Rails 2.3.1)
>> User.table_name
=> "tblusers"
>>
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
class User < PrefixModel
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment