Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Rails Pacific - Multitenancy with Rails
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ryan Bigg
October 25, 2014
Programming
310
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails Pacific - Multitenancy with Rails
Covers the lessons learned about Multitenancy with Rails in the process of writing my book.
Ryan Bigg
October 25, 2014
More Decks by Ryan Bigg
See All by Ryan Bigg
Hiring Juniors - RubyConf Indonesia 2019 Closing Keynote
radar
1
480
Web Directions - Code Leaders - Hiring Juniors
radar
0
720
The Future of Rails - Take 2
radar
0
170
The Future of Rails
radar
1
180
Exploding Rails
radar
9
1.9k
Hiring Juniors
radar
2
500
The Perfect Coding Test
radar
0
170
Your First Developer Job
radar
1
130
Hiring Juniors
radar
2
310
Other Decks in Programming
See All in Programming
npm との違いを手がかりにGo の依存管理を理解したい
optim
0
1k
APNsからLive Activityを開始する話
yumnumm
0
170
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.7k
ActionController meets Protocol Buffers
sorah
0
670
contenteditable と日本語入力に向き合う
colorful12
0
210
月間100万人のサービス刷新で、 技術選定をHonoに振り切った話
yutobara
8
6.8k
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
300
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
120
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
890
ジョジョの世界をXRで再現する
mofurune
0
180
Featured
See All Featured
Accessibility Awareness
sabderemane
1
250
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Mind Mapping
helmedeiros
1
400
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
Claude Code のすすめ
schroneko
67
230k
Become a Pro
speakerdeck
PRO
31
6.3k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.1k
Marketing to machines
jonoalderson
1
5.9k
Typedesign – Prime Four
hannesfritz
42
3.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Agile that works and the tools we love
rasmusluckow
331
22k
Transcript
lifx.co
#21 Not #21
Multitenancy with Rails Ryan Bigg
None
None
Multitenancy?
None
None
None
Organization Team Repos
User Repos
None
…
DOGLIFEBETA! Garçon Fluffy Brutus “Like Facebook, but for dogs”
Multitenancy with Rails?
None
Is it… ✔ well maintained ✔ well documented ✔ clean
code
acts_as_tenant ✔ well documented
acts_as_tenant ✔ well maintained ✔ 140 commits, 19 contributors, low
issue count ✔ CI on Travis
acts_as_tenant ✔ clean code
acts_as_tenant
RequestStore.store
None
Thread.current Thread.current
apartment ✔ well documented ✔ well maintained ✔ clean code
“If you are using PostgreSQL, Apartment by default will set
up a new schema and migrate into there.”
“If you are using PostgreSQL, Apartment by default will set
up a new schema and migrate into there.”
None
“A database contains one or more named schemas, which in
turn contain tables.” “There are several reasons why one might want to use schemas: * To allow many users to use one database without interfering with each other.”
“To allow many users to use one database without interfering
with each other.”
ryanbigg=# SHOW search_path; search_path ---------------- "$user",public (1 row) "$user",public
fluffy.doglife.com garcon.doglife.com DOGLIFE BETA! brutus.doglife.com 1 2 3
(1.4ms) CREATE SCHEMA "garcon" <more tables go here>
None
None
None
DEPLOY IT!
Heroku Postgres
Backup time 24 hours
PostgreSQL is great
PostgreSQL with too many schemas
Part 2: Schema-less Multitenancy
Apartment
None
TEST ALL THE TIME
TEST ALL THE TIME?
TEST ALL THE TIME
Are you testing right now? No?
TEST ALL THE TIME OR ELSE
A codebase without tests
fluffy.doglife.com Fluffy’s Posts current_account = Fluffy @posts = current_account.posts fluffy.doglife.com/posts
Feature #1: Viewing Posts
A guest on Account A’s subdomain should only see Account
A’s posts Expected to not see “<Account B’s post>” Feature #1: Viewing Posts
Feature #1: Viewing Posts
Feature #1: Viewing Posts
Feature #1: Viewing Posts
A guest on Account A’s subdomain should only see Account
A’s posts Feature #1: Viewing Posts
fluffy.doglife.com Fluffy’s Posts current_account = Fluffy @posts = current_account.posts fluffy.doglife.com/posts
Feature #1: Viewing Posts
fluffy.doglife.com Fluffy’s Albums current_account = Fluffy @albums = current_account.albums fluffy.doglife.com/albums
Fluffy’s First Birthday Pictures @pictures = @album.pictures fluffy.doglife.com/albums/1/pictures Feature #2: Viewing Pictures
A guest on Account A’s subdomain should only see Account
A’s albums Expected to not see “<Account B’s album>” Feature #2: Viewing Pictures
Feature #2: Viewing Pictures
Feature #2: Viewing Pictures
A guest on Account A’s subdomain should only see Account
A’s albums Feature #2: Viewing Pictures
A guest on Account A’s subdomain viewing an album shows
pictures from that album Expected to not see “<Account B’s picture>” Feature #2: Viewing Pictures
Feature #2: Viewing Pictures
Feature #2: Viewing Pictures
A guest on Account A’s subdomain viewing an album shows
pictures from that album Feature #2: Viewing Pictures
fluffy.doglife.com Fluffy’s Albums current_account = Fluffy @albums = current_account.albums fluffy.doglife.com/albums
Fluffy’s First Birthday Pictures @pictures = @album.pictures fluffy.doglife.com/albums/1/pictures Feature #2: Viewing Pictures
Feature #2: Viewing Pictures
REGRESSION TEST ALL THE TIME
Feature #2: Viewing Pictures
None
Part 3: Subscriptions
None
doglife.com/sign_up plan = Basic ($9.99) Feature #3: User subscribes to
a plan ???
“Writing code to manage subscriptions is easy.” - nobody, ever
Your subscriptions code
PayPal
None
PayPal
None
“Stripe makes recurring and subscription-based billing easy.”
None
None
None
:CreateRecurringPaymentsProfileRequestDetails PayPal
None
“My company makes your life easy.”
doglife.com/sign_up plan = Basic ($9.99) Feature #3: User subscribes to
a plan
None
[email protected]
[email protected]
⁉
[email protected]
leanpub.com/multi-tenancy-rails/c/railspacific $10 off