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

Rails Sign in using devise to authenticate from two db tables

I have 2 database tables namely coreteam and user. Both the models are configured with devise. For now to sign in for core team my API is: localhost:3000/api/v1/core_teams/sign_in with following request data. { "core_team": { "email":…
Bhagawat
  • 468
  • 4
  • 12
2
votes
1 answer

Devise Apartment create tenant on or after devise user create

I have a little app that is using devise and apartment gems. I have User(devise) who has one organization(tenant_name). The organization has one :owner, class_name 'user' I want to use the Devise registration form to also create the tenant and…
Joe Bloggos
  • 889
  • 7
  • 24
2
votes
2 answers

Rails and Apartment - Redirect after creating the tenant

I have a Domain model for creating the tenant. class Domain < ApplicationRecord after_create :create_tenant def create_tenant Apartment::Tenant.create(name) end end After creating the tenant "example" i want to redirect my browser…
Abhishek Aravindan
  • 1,432
  • 6
  • 23
2
votes
1 answer

Paperclip custom path with Apartment Gem

Facing very wired issue while using Paperclip (With s3 storage) and Apartment gem. Apartment gem is being used for multi-tenancy with Postgres DB. ( i.e Separate Schema for every tenant ) For Storage, I would like to create a separate folder for…
Solid
  • 307
  • 1
  • 12
2
votes
0 answers

Rails 5.1 Redirect to current_user.subdomain after_sign_in_path_for with apartment gem

Can't seem to get this to work. I am using the Apartment Gem and Devise and trying to redirect after sign_in to the users subdomain. When user first registers they are transferred to their subdomain; I just can't seem to get it to work once logged…
Charles Smith
  • 3,201
  • 4
  • 36
  • 80
2
votes
1 answer

How put apartment gem to work with ActionCable?

My Rails 5 app uses ActionCable and I have tenants (using the apartment gem). But ActionCable does not see the apartment middleware, so does not set the tenant. Does anyone have a way to make this all work together?
Bruno Wego
  • 2,099
  • 3
  • 21
  • 38
2
votes
1 answer

Devise: Login user and redirect to subdomain

I am using Apartment and Devise gem for Muti-tenancy and authentication. I have a sign_up page in root domain URL(example.com) where I get the subdomain details from user. I need to sign_in the user after successfully saving the record and redirect…
Gokul
  • 3,101
  • 4
  • 27
  • 45
2
votes
1 answer

Apartment current_tenant resets to 'public' after failed devise login

I use Devise for authentication and Apartment for multi-tenancy support on a SAAS app. After a failed login, devise "redirects" to the login page (Users::SessionsController#new) and the value of Apartment::Tenant.current which was previously set in…
2
votes
1 answer

Make a copy of tenant in apartment gem

I am using apartment gem with PostgreSQL and I need to make a copy of already existing tenant with data. One way which I can think of one way is to collect all data from the tenant and then switch tenant and start creating record. Below is a small…
Muaaz Rafi
  • 1,469
  • 2
  • 15
  • 23
2
votes
1 answer

Rails - Apartment - MySQL drop tenant database

I am creating a multi tenant application in rails using apartment gem and MySQL as database. I have setup apartment following https://gorails.com/episodes/multitenancy-with-apartment . After this whenever I created a new subdomain, new database was…
2
votes
1 answer

Disabling `pg_stat_statements` permanently in ActiveRecord + Postgres

I use the Apartment gem in Rails 4 to manage mult-tenancy in my Rails app. As explained by this question, the PG Stat Statments that attempt to execute require superuser privelage, which Heroku does not allow. So I followed the directions to…
user2490003
  • 10,706
  • 17
  • 79
  • 155
2
votes
1 answer

Multi-tenancy rails application to heroko deployment

I have developed a Rails multi-tenancy application using Apartment gem which works fine locally and I am able to test it using lvh.me:3000/ but, couldn't able to deploy it to heroku. However, heroku push finishes it the normal deployment process on…
bir_ham
  • 513
  • 5
  • 19
2
votes
2 answers

Rails Multi tenancy using Apartment gem on Amazon AWS

I have previously used apartment on Heroku, but now for a client, I am evaluating if it can be used on AWS. Is there a tutorial that shows how to use the apartment gem on Amazon AWS? After reading https://aws.amazon.com/running_databases/ , I am…
jumpa
  • 658
  • 1
  • 9
  • 22
2
votes
0 answers

Rails collating data from multiple schemas on Multitenant application

Before I set out on a big structural change in my app, I would like to know a bit more about the basics of multi-tentant apps implemented with Postgres' schemas in Rails. More objectively: I would like to know how to query accross schemas. Say I…
2
votes
2 answers

Migration wont recognize hstore extension created on schema_search_path

I´m trying to add a column using postgresql HStore. Since I´m running a multi tenant app (using apartment gem), I´ve created the hstore extension on a dedicated schema, called "shared_extensions", as seen here:…