Skip to content

Instantly share code, notes, and snippets.

@waynerobinson
Created October 30, 2012 02:51
Show Gist options
  • Save waynerobinson/3978036 to your computer and use it in GitHub Desktop.
Save waynerobinson/3978036 to your computer and use it in GitHub Desktop.
module MTData
module CityDatabaseConfig
def self.included(base)
base.establish_connection "mtdata"
city_name = self.to_s.match(/::(.+)::.+$/)[1]
base.table_name = "[#{city_name}].[dbo].[Place]"
end
end
class Perth
class Place << ActiveRecord::Base
include CityDatabaseConfig
end
end
class Brisbane
class Place < ActiveRecord::Base
include CityDatabaseConfig
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment