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

Rails & Apartment: switching tenant based on cookie or domain

I'm working on setting up a multi-tenant app using the Apartment gem and Rails 4.1. My approach is that the administrative interface will be hosted on a single domain and then serve up tenant-specific data on custom domains. Administrative users…
4
votes
1 answer

Issue when installing rails apartment gem

I am getting an error when I am trying to bundle exec rails generate apartment:install Getting this error, build': undefined method new' for "Apartment::Reloader":String (NoMethodError) Looks this is a middleware issue. Any solution.
Vivek
  • 53
  • 2
4
votes
1 answer

search_path in structure.sql file gets modified by rails db:migrate

Everytime I run rake db:migrate on my project the db/structure.sql changes and I'm happy. Unfortunately the changes are not only additions to my table but also something strage in explicitly using our tenant keyword and extensions…
4
votes
1 answer

duplicate keys conflict in using activerecord-import with apartment gem

I'm using activerecord-import gem to import many records in one DB insert, in the same project I'm using apartment gem to create and use multi postgres schemas and switch between many schemas realtime ... the issue is sometimes after import records,…
Yaman ALTareh
  • 286
  • 3
  • 12
4
votes
4 answers

How select specific tenant after enter on console?

The code below, stored at config/initializers/console.rb works only at first time I exec rails console CLI. When exit and enter again, no selection message is displayed, but the preview tenant selected is loaded. if defined?(Rails::Console) ||…
Bruno Wego
  • 2,099
  • 3
  • 21
  • 38
4
votes
1 answer

Creating New Tenant Apartment Gem - Always restart?

I have a rails 4.2 multi-tenant app using the Apartment gem which has been awesome. Each company has their own subdomain. I'm using a custom "elevator" which looks at the full request host to determine which "Tenant" should be loaded. When I create…
Steve Q
  • 395
  • 5
  • 28
4
votes
0 answers

Rails + Apartment + PostGIS + activerecord-postgis-adapter

I'm trying to enable postgis in a Apartment tenanted Postgresql database and I'm completely stuck. See this gist with all relevant pieces: https://gist.github.com/phildionne/6c5cdd210f4e91bd43bb apartment.rb configuration Apartment.configure do…
4
votes
1 answer

Devise and apartment gem multitenant app

My app currently only allows the user to sign_in on their subdomain i.e subdomain.domain.com/users/sign_in. I would like the users to login at domain.com/users/sign_in instead. I'm a Rails newbie and I got a lot of assistance with regards to…
Codelove
  • 68
  • 1
  • 9
4
votes
1 answer

How to use pg_dump without using Heroku tools?

I want to use pg_dump on a Heroku multi-schema pgSQL app using the apartment gem, but am afraid I have too many schemas to make it work. I looked into it and found the following from the creator of the apartment gem at the following link I'm the…
David Mckee
  • 1,100
  • 3
  • 19
  • 35
3
votes
1 answer

NameError wrong constant name primary — yet `primary` doesn't exist?

I am getting an error that randomly pops up whenever I make changes. If I refresh the page after getting the error, it goes away. The error: NameError wrong constant name primary I have searched my entire application and I do not have any methods…
ianrandmckenzie
  • 472
  • 3
  • 12
3
votes
1 answer

Query different schemas data in a rails application for read+write

I have two rails application base1 and base2. base1 uses db1 and have multiple tenants inside this database, its using apartment gem. base2 is single tenant application and has database db2 as primary, and also uses data from db1. Now the problem…
Abhishek Aravindan
  • 1,432
  • 6
  • 23
3
votes
1 answer

How to migrate existing rails application to multi-tenant application with Apartment?

I'm struggling to migrate existing single-tenant application to multi-tenant application with Apartment and Devise without using subdomains. I already have an application that has Company and multiple users who belong to that company. Now I need to…
Martynas Jurkus
  • 9,231
  • 13
  • 59
  • 101
3
votes
1 answer

Apartment and Devise not creating tenant

Hi I am working with apartment for the first time following along with https://gorails.com/episodes/multitenancy-with-apartment?autoplay=1 but I am using devise for authentication. When I go to create a new user and tenant I get the following error …
Jeremy Bray
  • 444
  • 5
  • 18
3
votes
2 answers

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

when doing rake db:migrate, I am getting this error: Migrating alpha tenant One of the following schema(s) is invalid: "alpha" "public" My apartment initializer configs: require 'apartment/elevators/subdomain' # require…
Jaswinder
  • 1,455
  • 14
  • 27
3
votes
1 answer

rails apartment gem copy data from one tenant to another

I am creating a multi-tenant rails app for technical training centers. I'm using the apartment gem so it creates different databases for each tuition center which has trainers and students. Students have their complete progress assessment data with…
1
2
3
11 12