Skip to content

Commit

Permalink
Merge pull request #11 from virtualstaticvoid/generator
Browse files Browse the repository at this point in the history
Added Rails generator for apartment initializer
  • Loading branch information
bradrobertson committed Oct 29, 2012
2 parents f9e9fa3 + 57b354c commit 9c1c385
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/generators/apartment/install/USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Description:
Creates an initializer for apartment.

Example:
`rails generate apartment:install`
10 changes: 10 additions & 0 deletions lib/generators/apartment/install/install_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module Apartment
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../templates', __FILE__)

def copy_files
template "apartment.rb", File.join("config", "initializers", "apartment.rb")
end

end
end
35 changes: 35 additions & 0 deletions lib/generators/apartment/install/templates/apartment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
##
# Apartment Configuration
Apartment.configure do |config|

# these models will not be multi-tenanted,
# but remain in the global (public) namespace
config.excluded_models = %w{
ActiveRecord::SessionStore::Session
}

# use postgres schemas?
config.use_postgres_schemas = true

# configure persistent schemas (E.g. hstore )
# config.persistent_schemas = %w{ hstore }

# add the Rails environment to database names?
# config.prepend_environment = true
# config.append_environment = true

# supply list of database names
config.database_names = lambda{ ToDo_Tenant_Or_User_Model.scoped.collect(&:database) }

end

##
# Elevator Configuration

# Rails.application.config.middleware.use 'Apartment::Elevators::Domain'

# Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'

Rails.application.config.middleware.use 'Apartment::Elevators::Generic', Proc.new { |request|
# TODO: supply generic implementation
}

0 comments on commit 9c1c385

Please sign in to comment.