Class: Roomer::Generators::SetupGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Roomer::Generators::SetupGenerator
- Extended by:
- ActiveRecord::Generators::Migration
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/roomer/setup/setup_generator.rb
Instance Method Summary collapse
-
#create_migration_file ⇒ Object
creates a migration file under /db/migrate/shared_schema_name.
-
#create_tenant_model_file ⇒ Object
Creates the Tenants model file under /app/models.
Instance Method Details
#create_migration_file ⇒ Object
creates a migration file under /db/migrate/shared_schema_name
32 33 34 |
# File 'lib/generators/roomer/setup/setup_generator.rb', line 32 def create_migration_file migration_template "global_migration.rb", "#{Roomer.shared_migrations_directory}/roomer_create_#{Roomer.tenants_table.to_s}" end |
#create_tenant_model_file ⇒ Object
Creates the Tenants model file under /app/models
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/generators/roomer/setup/setup_generator.rb', line 12 def create_tenant_model_file add_file File.join(Roomer.model_directory,"#{Roomer.tenants_table.to_s.singularize}.rb") do <<-CONTENT class #{Roomer.tenants_table.to_s.classify} < ActiveRecord::Base # load tenanted schema.rb file to provision new tenant after_create :load_schema # tell roomer if this is a shared model roomer :shared protected def load_schema Roomer::Schema.load(schema_name) end end CONTENT end end |