diff --git a/Gemfile b/Gemfile index 0635a9f..594aed8 100644 --- a/Gemfile +++ b/Gemfile @@ -11,6 +11,7 @@ gem 'nokogiri' gem 'pg' gem 'activerecord-postgis-adapter' gem 'inherited_resources' +gem 'apartment' gem 'jquery-rails' @@ -42,5 +43,6 @@ group :development, :test do gem 'rb-inotify', '~> 0.8.8' gem "better_errors" gem "binding_of_caller" +# gem 'database_cleaner' end diff --git a/Gemfile.lock b/Gemfile.lock index ac6b0b8..0e43c8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -39,6 +39,9 @@ GEM i18n (= 0.6.1) multi_json (~> 1.0) addressable (2.3.2) + apartment (0.20.0) + activerecord (>= 3.1.2) + rack (>= 1.3.6) arel (3.0.2) better_errors (0.7.0) coderay (>= 1.0.0) @@ -193,6 +196,7 @@ PLATFORMS DEPENDENCIES activerecord-postgis-adapter + apartment better_errors binding_of_caller carrierwave diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index d8d2124..798fe97 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -296,6 +296,7 @@ def set_agency if @agency.nil? not_found end + Apartment::Database.switch( @agency.slug ) else not_found end diff --git a/config/initializers/apartment.rb b/config/initializers/apartment.rb new file mode 100644 index 0000000..c05513d --- /dev/null +++ b/config/initializers/apartment.rb @@ -0,0 +1,5 @@ +Apartment.configure do |config| + config.persistent_schemas = ['postgis'] + config.default_schema = "public" + config.excluded_models = ["Agency"] +end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 843cabf..100e56f 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -19,6 +19,7 @@ namespace :stargtfs do args[:agencies].split(/:/).each do |cityname| citysym = cityname.to_sym if Importers.has_key? citysym + Apartment::Database.switch( cityname ) importer = Importers[citysym].new importer.run else