-
Notifications
You must be signed in to change notification settings - Fork 460
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from virtualstaticvoid/generator
Added Rails generator for apartment initializer
- Loading branch information
Showing
3 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |