Multitenancy with Rails by Ryan Bigg
Author:Ryan Bigg [Bigg, Ryan]
Language: eng
Format: azw3
Published: 2015-08-07T16:00:00+00:00
By having this middleware located here, the things should be well on their way to being scoped. Let’s find out if they’re there by running the test again. When we do that, we’ll see the first test fails like this:
Failure/Error: visit main_app.things_url(:subdomain => account_b.subdomain) ActiveRecord::RecordNotFound: Couldn't find Subscribem::Account with id=<id>
This test is failing because it can’t find an account. That much is pretty obvious from the error message. But why can’t it find an account? For that answer, we must look deeper. This issue is actually caused by the schema switching stuff we have just implemented. The root of this problem is that the schema lookup path no longer contains the schema which contains the accounts: the public schema.
To fix that problem, we can exclude some models from Apartment’s scoping. We only need to exclude the Subscribem::Account model for now, but later on we’ll need to do the Subscribem::Member and Subscribem::User too, so let’s exclude both of these models now with these lines in a new file called config/initializers/apartment.rb:
Apartment.excluded_models = ["Subscribem::Account", "Subscribem::Member", "Subscribem::User"]
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(11915)
Hello! Python by Anthony Briggs(9379)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9350)
The Mikado Method by Ola Ellnestam Daniel Brolund(9316)
Dependency Injection in .NET by Mark Seemann(8864)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7858)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7336)
Grails in Action by Glen Smith Peter Ledbrook(7303)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7123)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(5965)
Kotlin in Action by Dmitry Jemerov(4653)
Practical Vim (for Kathryn Amaral) by Drew Neil(3729)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3599)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3432)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3250)
Learning Java by Patrick Niemeyer & Daniel Leuck(2872)
Learning React: Functional Web Development with React and Redux by Banks Alex & Porcello Eve(2842)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(2763)
Mastering Java 9 by Dr. Edward Lavieri(2574)