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
26
votes
1 answer

How to get current tenant when using Appartment gem in multi-tenancy Rails 4

How can I find out which tenant (schema) is the current one when Apartment was initialized according to request
13
votes
1 answer

Apartment ruby gem : Want to Catch an exception

I am using this apartment a ruby gem. I have add this in application.rb file: config.middleware.use 'Apartment::Elevators::Subdomain' When i try hit this in browser url 'test.domain.local:3000' where sub domain 'test' schema does not exist in…
user1969191
  • 282
  • 1
  • 12
11
votes
1 answer

Heroku + Apartment PG::Error: ERROR: function pg_stat_statements_reset() does not exist

I use Apartment gem in Rails 4 to support multi-tenancy in Postgres 9.3.3 on Heroku. An error is occurred when Apartment gem creates a new tenant. Deep investigation showed that a schema was created, but no tables inside. Heroku logs showed an…
9
votes
0 answers

How can I setup Minitest fixtures to test Apartment using postgres schemas

I am building a multi tenant app in Rails using the Apartment Gem and Postgresql 9.4.1. I use Minitest and dont' know RSpec. How can I setup Minitest fixtures to put some fixtures/data in the public schema and some other data in a specific…
Adam21e
  • 791
  • 5
  • 13
8
votes
1 answer

Config apartment-gem for MySQL using structure.sql instead of schema.rb to create a new tenant

I need View SQL and Stored Procedure in my Rails app so I have to change from schema.rb to structure.sql. This is my config in config/application.rb config.active_record.schema_format = :sql but then when I create a new record for an entity in…
bird
  • 1,872
  • 1
  • 15
  • 32
7
votes
1 answer

How to drop all schemas in PostgreSQL with SQL query?

I need to drop all the schemas in my database except public, information_schema and those LIKE 'pg_%'. Here's what I've found: (this variant doesn't seem to work) CREATE OR REPLACE FUNCTION drop_all () RETURNS VOID AS $$ DECLARE rec…
6
votes
2 answers

Rails 5, Apartment and Devise: sign in with subdomains are not working

I’ve setup a Rails 5 application with Apartment (1.2.0) and Devise (4.2.0). Due to some DDNS issues there is the constraint that the app is only reachable under app.myapp.com (note the subdomain app). myapp.com redirects to app.myapp.com. My use…
6
votes
2 answers

How do I manage connection pooling to PostgreSQL from sidekiq?

The problem I have a rails application that runs a few hundred sidekiq background processes. They all connect to a PostgreSQL database which is not exactly happy about providing 250 connections - it can, but if all sidekiq processes accidentally…
Niels Kristian
  • 8,661
  • 11
  • 59
  • 117
6
votes
1 answer

Best way to customize CSS for tenants on a multi-tenant app?

I'm using the Apartment gem to build a multi-tenant app (each tenant lives in a different Postgres schema). What's the best way in Rails to define custom CSS overrides for each tenant?
Jacob
  • 6,317
  • 10
  • 40
  • 58
5
votes
1 answer

PG::InFailedSqlTransaction on creating initial tenant

I'm converting my Rails project to multi-tenant and I'm using Apartment. I followed the directions on their README and the video they link to My apartment.rb looks like this: require 'apartment/elevators/subdomain' Apartment.configure do |config| …
Andy
  • 285
  • 3
  • 12
5
votes
2 answers

How to test Apartment, Minitest, Capybara & Selenium

I'm new with Minitest and Apartment and have difficulties to configure the environment correctly to run the test cases. I want to make acceptance testing using Capybara & Selenium. When I run my tests I get following error…
talakoski
  • 131
  • 1
  • 8
5
votes
2 answers

How to handle urls in emails with apartment gem

I am using the apartment gem for multi-tenancy. Everything works fine besides urls in my emails. So for each email which is sent from any requests and from background jobs are using the default_url_options for the host. Any suggestions on how to…
Bogdan
  • 453
  • 4
  • 16
5
votes
0 answers

How to test multi-tenant apps on Heroku staging?

I currently am creating a multi-tenant application using Rails, Heroku and the Apartment gem. ( Please note I am aware of the limitations of using the multitenant app structure on Heroku for more than 10 different databases ). I properly set up my…
LMo
  • 1,429
  • 2
  • 15
  • 32
5
votes
1 answer

Apartment switch tenant based on logged user

I'm trying to implement a custom elevator for apartment based on user login on a per request basis. Basically what I'm trying to achieve is: Every time a request comes in, switch to the correct tenant If there's no logged user, the default tenant…
Nuno
  • 515
  • 1
  • 5
  • 21
5
votes
1 answer

Rails - Apartment gem - Different schema for public and tenant database

I know by default Apartment will create same tables on both public and tenant database. And most of tables on public database are no use, empty tables. I also know that tenant database are depending on schema.rb But I wonder if we can have different…
Ankita Agrawal
  • 422
  • 5
  • 20
1
2 3
11 12