Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Rails generator for apartment initializer #11

Merged
merged 1 commit into from
Oct 29, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}