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
2
votes
0 answers

Apartment (ruby gem) to host customers' websites?

TL;DR: Assets, partials, layouts, gem configurations, other code shared among apps Different database for every app Ability to update codebase across all apps at once, not affecting custom code on client's site Apartment? Rails Engine?…
foxtrotuniform6969
  • 3,527
  • 7
  • 28
  • 54
2
votes
1 answer

How to truncation all data in a schema different from the Public (database_cleaner)

In my project I use database multi-tenancy 'apartment' gem. config/initializers/apartment.rb Apartment.configure do |config| config.excluded_models = %w{ User Company } end To clean up the database it tests I use 'database_cleaner'…
2
votes
0 answers

Stop migrations from a particular gem

I am working on a multi tenant rails app where the tenants have been created using Apartment gem. Whenever a new tenant is created, Apartment creates all the tables in the new tenant. But, when I add a new table and run db:migrate, one of the gems,…
jumpa
  • 658
  • 1
  • 9
  • 22
2
votes
1 answer

How can I have multiple schemas and multiple subdomains when hosting on Heroku?

I am planning on using Devise and Apartment in my upcoming application to create subdomains for each organization that creates an account. I would like to host my application on Heroku, but ran across the following quote: The most common use case…
David Mckee
  • 1,100
  • 3
  • 19
  • 35
1
vote
1 answer

How to redirect user to a page with different subdomain after sign_in/sign_out devise?

I have a problem with redirecting to subdomain after devise sign_in or sign_out. I generated devise controllers uncommented methods that should take me where I want but subdomains don't work. def after_sign_in_path_for(resource) …
1
vote
0 answers

Rails/Multitenancy - How to transfer data from one account to another when using Apartment gem?

I am using the Apartment gem for multitenancy and this separates the database for each tenant. Now I have a request to make a function to copy objects from one tenant to another. I've come across this answer but I think this would create a…
1
vote
1 answer

How can I ensure Sidekiq background jobs run against the same database they were initiated from

I have been implementing horizontal database sharding in Rails 6.1 using the new native multiple database connection switching. This has worked great in general, but I am trying to find the best way ensure that background jobs (via Sidekiq backed by…
rockyroadster555
  • 313
  • 1
  • 4
  • 15
1
vote
1 answer

Setting up comfy cms fails with multi-tenancy app

I've got an app for which I'd like to use the comfy cms. I did the following: added gem "comfortable_mexican_sofa", "~> 2.0.0" bundle install rails g comfy:cms When I try to migrate I get the following error: ArgumentError: wrong number of…
1
vote
0 answers

How do I lazy-load a config from an initializer?

I'm using Rails 6 with the 'money-rails' gem (for multiple currencies) and 'apartment' gem (for multi-tenancy). In the 'money-rails' documentation it is said that I could lazy-load the configuration of the default currency of the app, by using doing…
1
vote
0 answers

GitHub Codespaces subdomain

I run the Ruby on Rails application on the GitHub Codespaces. It works fine when I am not logged in. But when I log in, it will be redirected to the subdomain by Apartment GEM. And get an error message NET::ERR_CERT_COMMON_NAME_INVALID. Is there any…
Amo Wu
  • 2,507
  • 2
  • 18
  • 22
1
vote
1 answer

Rails - copy a Table from one schema to another schema in same database

Following is my setups: Ruby version: 3.0.1 Rails Version: 6.1.3.2 postgres (PostgreSQL) 9.6.17 I am using gem ros-apartment (2.9.0) to manage tenants. This is what I have in my apartment.rb config.tenant_names = -> { Tenant.pluck :app_name…
Bhagawat
  • 468
  • 4
  • 12
1
vote
0 answers

Making a request to an ActiveStorage resource fails occasionally when used alongside Apartment gem

Use-case We're using Apartment gem alongside ActiveStorage. In our Amazon S3 server, we have created a bucket for every tenant in our application. Since ActiveStorage can hold only one bucket globally, we're switching the ActiveStorage bucket for…
1
vote
1 answer

Apartment::TenantNotFound (Error while connecting to tenant 34: FATAL: database "34" does not exist

I am using ros-apartment gem for multi tenancy in rails application. I have deployed the application on AWS and sometime I get below error: Apartment::TenantNotFound (Error while connecting to tenant 34: FATAL: database "34" does not exist): And…
Gaurav Patil
  • 1,162
  • 10
  • 20
1
vote
1 answer

Action cable in rails application with subdomain - apartment gem isn't working

Rails 5, apartment gem action cable connection.rb module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user, :tenant def connect self.tenant = request.subdomain …
ramamoorthy_villi
  • 1,939
  • 1
  • 17
  • 40
1
vote
0 answers

Write RSpec tests for APIs with apartment gem

I added the apartment gem to my project, and everything is working well in my development, and I haven't any problem. Right now, I want to update my RSpec tests with tenant subdomains. I added: Apartment::Elevators::Subdomain.excluded_subdomains =…
Hamid
  • 41
  • 2