Questions tagged [apartment-gem]

Database multi-tenancy for Rack (and Rails) applications

Apartment provides tools to help you deal with multiple tenants in your Rails application. It helps you to have certain data sequestered based on account or company, but still allow some data to exist in a common tenant.

Resources:

176 questions
0
votes
1 answer

What is the proper way of merging multiple postgres schemas into a single schema preserving the foreign key relationships?

We have a SAAS platform written in Rails using the postgres' schema based multitenancy and Apartment gem. The different schemas are identical, with same number of tables and same columns in each table. We want to migrate to foreign key based…
0
votes
0 answers

Migrating db with rails gem apartment and multi-tenant returns PG::InvalidSchemaName

I run rake db:migrate and I get the following error: PG::InvalidSchemaName: ERROR: no schema has been selected to create in LINE 1: CREATE TABLE "schema_migrations" ("version" character varyin.. This is on Rails 6, with gem…
0
votes
1 answer

Postgresql 9.6 with multi-tenancy - INHERIT says child table has column with different data type but it doesn't

I've been working with a legacy rails app that has had the same "inherit" migration that has run plenty of times in the past but suddenly is complaining that one of the child tables has a column of different type than the parent table in the public…
Joe Sak
  • 770
  • 6
  • 13
0
votes
1 answer

Rails Apartment: Adding www. redirects to public tenant

I'm having a problem with creating a multi-tenancy app with Ruby on Rails, using the apartment gem. The problem is that whenever I add www. to the start of my web URL, it takes me back to the public tenant. I am using Heroku and google domains to…
Chase
  • 77
  • 1
  • 11
0
votes
1 answer

Rails Active Storage with multi-tenancy using apartment gem

I have a rails app with multi-tenancy implemented using apartment gem. I have a model called Report that is excluded from multi-tenancy, i.e it is common to all tenants. # app/models/report.rb class Report < ApplicationRecord has_one_attached…
0
votes
1 answer

Apartment: uninitialized constant Tenant (NameError)

I am using the Apartment Gem for the first time for Multitenancy in a Ruby on Rails project. I am trying to create multiple tenants for users in your digital library Rails application. I am using Devise Gem for the authentication of the…
Promise Preston
  • 24,334
  • 12
  • 145
  • 143
0
votes
1 answer

Schema selection in Apartment gem not working as expected

In a demo application we want to handle tenants in different schemas (default apartment configuration for Postgres). These are to be selected from the subdomain of the application url. I got it working, but then broke it again (it started using…
estani
  • 24,254
  • 2
  • 93
  • 76
0
votes
0 answers

How to get login info from request.env?

I am using rails as a back end API for a SaaS project. I want to use the generic elevator of the Apartment gem. I dont use devise or warden, simple User model. How do i get info from request.env to find the tenant name in the User model.
0
votes
1 answer

Appartment elevator with login info

I’m doing a Rails SaaS backend using Apartment gem and I need to use the data passed in the login as elevator. How do I proceed? Thanks.
0
votes
1 answer

How to switch to specific database for specific model in rails?

I am using apartment gem where it has multi tenancy. I want to have a solution like whenever that particular model is called or any execution happen it should switch to that specific database. model name = RakeLog main db_name = ABC another db_name…
0
votes
1 answer

disabling subdomains with Apartment

I'm using the apartment gem in a rails app. I have one database with schemas for each tenant and one public schema for the Tenant table. I have excluded the www subdomain: Apartment::Elevators::Subdomain.excluded_subdomains = ['www'] Then, if I…
lcjury
  • 1,158
  • 1
  • 14
  • 26
0
votes
3 answers

`Apartment::Tenant.switch!` during `bin/rails console` using `pry`

when console is launched while at console prompt How it should work? See the output here. Simple, quick methods. T.me (current tenant), T.names (tenants in the DB), ... Launch, ask for tenant selection, set $ bin/rails c Running via Spring…
Ram on Rails
  • 1,299
  • 11
  • 25
0
votes
2 answers

How to setup multi-tenant rails app with an admin

I am having a problem with how will I correctly set the models of my rails application. I will use the gem Apartment for multi-tenancy and the gem Devise for authentication. What I want to achieve is that I will have 3 user levels. The admin, owner,…
dcangulo
  • 1,888
  • 1
  • 16
  • 48
0
votes
1 answer

Apartment gem - Adding current database to all server logs

I am using the Apartment gem to switch the tenant (database) being used for a multi tenancy Rails application. In my server logs I would like to output the current tenant (database) being used for every single line in the log file. When I do rails s…
slindsey3000
  • 4,053
  • 5
  • 36
  • 56