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
1
vote
0 answers

Error in ActionCable with Apartment gem and Stimulus Reflex

I'm developing a multi tenant app, in Rails 6 with ActionCable, the gem Apartment and Stimulus Reflex. connection.rb ` module ApplicationCable class Connection < ActionCable::Connection::Base identified_by :current_user def connect tenant =…
1
vote
1 answer

Fixtures for Apartment Gem

I'm trying to do some tests with my multi-tenancy rails app but getting into trouble with my fixtures. In my controller test I have the following setup: setup do Apartment::Tenant.create('test') Apartment::Tenant.switch! 'test' host!…
tiloman
  • 75
  • 7
1
vote
1 answer

Updating a record through the rails console when using the Apartment gem

I'm working on a multi-tenant application via the Apartment gem. Everything is working perfectly, but I'm curious about something. How would one go about updating a record for a given tenant in the rails console? For example, If I do the following…
merovingian
  • 45
  • 1
  • 8
1
vote
1 answer

Rails : Multi-tenancy using Apartment and MySQL

I'm creating an application (on rails 6.0.1) using the Apartment gem & Devise, but i can't figure out how to make it work using MySQL.. I've made all my config and stuff, generating my User devise model etc. but when i'm trying to rails db:migrate…
Perdixo
  • 1,021
  • 3
  • 15
  • 31
1
vote
1 answer

Apartment: TenantNotFound - One of the following schema(s) is invalid

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
1
vote
0 answers

React not passing authorization header to rails api

I am using React frontend with a graphql rails api backend for a SaaS project with apartment. I need to get the authorization token from request.env so i can decode the user_id to get the tenant name which is a field in the User model. This is for a…
1
vote
1 answer

Running custom rake task for multi tenant app rails

I have a custom rake task namespace :abc do desc "seeds abc to a database" do task seed_abc: :environment do Tenant.find_each do |tenant| puts "Running task for tenant#{tenant.name}" Dir[File.join(Rails.root, 'db',…
1
vote
0 answers

What is a better way for this solution - Different Database for saving user data in multi tenant rails application

I have scenario for saving the information like name, address and other personal details of a user in a separate database so later the application admin operate on that data. I'm using Apartment gem for multi tenancy.Other than separate database, Is…
Abhishek Aravindan
  • 1,432
  • 6
  • 23
1
vote
1 answer

Heroku + Apartment: Apartment::FileNotFound: /app/db/schema.rb doesn't exist yet

I'm building a SAAS platform with heroku and Rails. For these, I'm managing the tenant with apartment gem. In my local development this found without issues, but when I tried to use into heroku appear the next error: /app/db/schema.rb doesn't…
1
vote
0 answers

How can I add read replication to a multi-tenant (Apartment) Rails App?

I have an existing, large Rails app, servicing customers. My predecessors used the Apartment gem to partition the business customers into separate DBs within MySQL (really, Aurora on AWS). They also started using Octopus to direct some of the DB…
1
vote
3 answers

How to store "macros" in rails console?

I have a multi-tenant rails app that uses the apartment gem. When I use rails console, I am constantly calling Apartment::Tenant.switch to navigate between apartments. I would like to create a config file somewhere that where I can abreviate this…
sakurashinken
  • 3,940
  • 8
  • 34
  • 67
1
vote
1 answer

Rails 5.2: No such middleware to insert before: "Warden::Manager"

I get this error trying to run a local rails server for an app upgraded to Rails 5.2 beta2: gems/actionpack-5.2.0.beta2/lib/action_dispatch/middleware/stack.rb:108:in `assert_index': No such middleware to insert before: "Warden::Manager"…
rigyt
  • 2,219
  • 3
  • 28
  • 40
1
vote
1 answer

How to redirect user after registration in apartment gem

I am using apartment gem to achieve multitenancy. When registers on the app I want to redirect him to his own url example for localhost (xyz.localhost:3000) etc. for registration I am getting all the necessary data. a. email, b. first_name ,…
thedudecodes
  • 1,479
  • 1
  • 16
  • 37
1
vote
0 answers

How to create association with excluded model in rails with apartment gem?

I have the following setup in rails class Book < AR has_one :assignment class Assignment < AR belongs_to :book My problem is that the assignment is an excluded model in a multi-tenant rails app while book is not. With apartment it is easy to…
sakurashinken
  • 3,940
  • 8
  • 34
  • 67
1
vote
1 answer

Foreign key issue with apartment gem is there any other solution to insert data in associate table

Following is the error I get when I add data in the associated model from the master database. ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR: insert or update on table "configurations" violates foreign key constraint…