Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/roomer/extensions/active_record.rb
Class Method Summary (collapse)
-
+ (Symbol) roomer(scope)
Sets the roomer scope for the model and changes the model’s table_name_prefix If :shared is passed, the global schema will be used as the table name prefix if :tenanted is pased, the current tenant’s schema will be used as the table name prefix.
-
+ (String) table_name_prefix
Overrides ActiveRecord::Base.table_name_prefix Defaults to blank if roomer class method is not set in model Returns the shared schema name prefix if roomer method is set to :shared Returns the current tenants schema name if roomer class method is set to :tenanted.
Class Method Details
+ (Symbol) roomer(scope)
Sets the roomer scope for the model and changes the model’s table_name_prefix If :shared is passed, the global schema will be used as the table name prefix if :tenanted is pased, the current tenant’s schema will be used as the table name prefix
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/roomer/extensions/active_record.rb', line 24 def roomer(scope) case scope when :shared @roomer_scope = :shared when :tenanted @roomer_scope = :tenanted else raise "Invalid roomer model scope. Choose :shared or :tenanted" end end |
+ (String) table_name_prefix
Overrides ActiveRecord::Base.table_name_prefix Defaults to blank if roomer class method is not set in model Returns the shared schema name prefix if roomer method is set to :shared Returns the current tenants schema name if roomer class method is set to :tenanted
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/roomer/extensions/active_record.rb', line 9 def table_name_prefix return @table_name_prefix unless @table_name_prefix.blank? if Roomer..to_s elsif tenanted? self.current_tenant[Roomer.tenant_schema_name_column] else "" end end |