apartment-gem

Issue when installing rails apartment gem

拥有回忆 提交于 2020-08-08 06:34:17
问题 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. 回答1: In order to use Rails 6 you have to use the development branch on github: gem "apartment", git: 'git@github.com:influitive/apartment.git', branch: "development" 来源: https://stackoverflow.com/questions/59590162/issue-when-installing-rails-apartment-gem

Foreign key issues with Apartment gem

亡梦爱人 提交于 2020-07-19 05:21:37
问题 Getting the below error with associated (belongs_to) models: PG::ForeignKeyViolation: ERROR: insert or update on table "employees" violates foreign key constraint "fk_rails_0d62068e18" DETAIL: Key (contract_type_id)=(2) is not present in table "contract_types". : INSERT INTO "employees" ("title_id", "surname", "othernames", "department_id", "job_title_id", "gender_id", "date_of_birth", "contract_type_id", "employee_status_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8

Active Admin and the Apartment Gem

*爱你&永不变心* 提交于 2020-01-02 07:04:49
问题 I am new to Active Admin but from what I have seen so far I think this is quite easy to implement. I have an app with the apartment gem to add multi-tenancy. I am adding active admin to my app. Apartment uses PostgreSQL schemas to segregate data. So for example by default your models in Apartment have a 'public' tenant unless you call something like Apartment::Tenant.switch!('abc') . In my app my User and Company model are in the public tenant and everything else is in tenants. So out of the

`Apartment::Tenant.switch!` during `bin/rails console` using `pry`

走远了吗. 提交于 2019-12-25 03:26:16
问题 when console is launched while at console prompt How it should work? See the output here. Simple, quick methods. T.me (current tenant), T.names (tenants in the DB), ... Launch, ask for tenant selection, set $ bin/rails c Running via Spring preloader in process 11233 Loading development environment (Rails 5.1.5) (1.9ms) SELECT "public"."tenants"."subdomain" FROM "public"."tenants" WHERE "public"."tenants"."deleted_at" IS NULL ORDER BY "public"."tenants"."created_at" DESC Available tenants: {0=

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

跟風遠走 提交于 2019-12-24 08:12:08
问题 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 application, and I have generated the and I have generated config file by running the code below in my terminal rails generate devise:install I have also generated a User model for Devise using the code below in my terminal rails generate devise User And for

Switching Apartment tenants in Active Admin

依然范特西╮ 提交于 2019-12-11 10:37:49
问题 This is an extension of my previous post: Active Admin and the Apartment Gem I thought I had this working but I am stuck. I have a Company model in the public schema as the tenant model and Locations in individual tenants. Here is my Active Admin location.rb file: ActiveAdmin.register Location do #Apartment::Tenant.switch!('abc') controller do #Apartment::Tenant.switch!('abc') before_filter do Apartment::Tenant.switch!('abc') skip_authorization skip_policy_scope end end end The skip

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

主宰稳场 提交于 2019-12-09 16:32:45
问题 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 error: PG::Error: ERROR: function pg_stat_statements_reset() does not exist 回答1: When a new schema is created Postgres is trying to reset stats by executing the function pg_stat_statements_reset() By default, this function can only be executed by

How to define seed file for Rails Apartment

六眼飞鱼酱① 提交于 2019-12-05 06:19:40
问题 I have set up the schema file but unable to define seed file for tenant such that it can run only for tenant migration only. Also I ma trying to create schema once a user has been created and its tenant is created. require 'apartment/elevators/subdomain' # # Apartment Configuration # Apartment.configure do |config| config.excluded_models = ["Admin","Contractor", "ContractorPackage","ContractorTransaction","Country","Currency","Faq","FaqCategory","Language","Package","Page","PaymentType",

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

余生颓废 提交于 2019-12-04 03:55:21
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 error: PG::Error: ERROR: function pg_stat_statements_reset() does not exist When a new schema is created Postgres is trying to reset stats by executing the function pg_stat_statements_reset() By default, this function can only be executed by superusers (from original doc) . Heroku doesn't give you superuser privileges. So you need to disable extension pg

How to define seed file for Rails Apartment

让人想犯罪 __ 提交于 2019-12-03 20:20:42
I have set up the schema file but unable to define seed file for tenant such that it can run only for tenant migration only. Also I ma trying to create schema once a user has been created and its tenant is created. require 'apartment/elevators/subdomain' # # Apartment Configuration # Apartment.configure do |config| config.excluded_models = ["Admin","Contractor", "ContractorPackage","ContractorTransaction","Country","Currency","Faq","FaqCategory","Language","Package","Page","PaymentType","Setting","TempTransaction","Testimonial","Timezone","Tutorial"] # use postgres schemas? config.use_schemas