Sha256: eca2f1b1da58271b680d967a4d3534a3d090425e8ad7fde30cce84d625b7f4c7
Contents?: true
Size: 1.95 KB
Versions: 7
Compression:
Stored size: 1.95 KB
Contents
require 'rails' require 'apartment/tenant' require 'apartment/reloader' module Apartment class Railtie < Rails::Railtie # # Set up our default config options # Do this before the app initializers run so we don't override custom settings # config.before_initialize do Apartment.configure do |config| config.excluded_models = [] config.use_schemas = true config.tenant_names = [] config.seed_after_create = false config.prepend_environment = false config.append_environment = false config.tld_length = 1 end ActiveRecord::Migrator.migrations_paths = Rails.application.paths['db/migrate'].to_a end # Hook into ActionDispatch::Reloader to ensure Apartment is properly initialized # Note that this doens't entirely work as expected in Development, because this is called before classes are reloaded # See the middleware/console declarations below to help with this. Hope to fix that soon. # config.to_prepare do Apartment::Tenant.init unless ARGV.include? 'assets:precompile' end # # Ensure rake tasks are loaded # rake_tasks do load 'tasks/apartment.rake' require 'apartment/tasks/enhancements' if Apartment.db_migrate_tenants end # # The following initializers are a workaround to the fact that I can't properly hook into the rails reloader # Note this is technically valid for any environment where cache_classes is false, for us, it's just development # if Rails.env.development? # Apartment::Reloader is middleware to initialize things properly on each request to dev initializer 'apartment.init' do |app| app.config.middleware.use "Apartment::Reloader" end # Overrides reload! to also call Apartment::Tenant.init as well so that the reloaded classes have the proper table_names console do require 'apartment/console' end end end end
Version data entries
7 entries across 7 versions & 1 rubygems