Ruby on Rails 6: Learn to Build a Multitenancy Subscriptions SaaS MVP


22 Chapters
177 Lessons
Created 06/2020
Last updated 06/2022
English
All levels
Certificate of Completion
Access to Member-Only Q&A
Access to Member-Only Resources
Full Lifetime Access & Updates
Hello, Ruby on Rails enthusiast!!

After 6 months of work, I proudly present to you this Ruby on Rails course.

The core topics of the course are :
  • multitenancy 
  • subscriptions
Why? Because nowadays, when it comes to building web applications, the real money lies in:
  • building apps for managing business processes (B2B)
  • the Software as a Service business model
For the creation of the course and the application itself, I was deeply inspired by Laravel Spark.

By the end of the course you will:
  • create your own SaaS multitenancy boilerplate step by step, feature by feature
  • feel capable of building the next Salesforce, Slack or Trello
Core features that you will master:

1. Multitenancy - complete implementation of row-based multitenancy with acts_as_tenant
2. Devise invitable - invite users via email
3. Advanced oAuth - connect multiple social accounts for one user
4. Internationalization (i18n) - whole translation guide
5. Authorization (role-based access) without any gems
6. ActiveStorage and AWS S3 - upload files to cloud storage
7. Omnicontacts - feature to import google contacts
8. Plan-based restrictions - limit access to different features
9. Admin dashboard - build an admin interface without any gems
10. Subscriptions engine - fully integrate the SaaS business model
11. Stripe integration - receive subscription payments from users

Gems covered:

  1. acts_as_tenant
  2. devise
  3.  simple_form
  4.  devise_invitable
  5.  friendly_id
  6.  active_storage_validations
  7.  aws-sdk-s3
  8.  exception_notification
  9.  invisible_captcha
  10.  omniauth-google-oauth2
  11.  omniauth-github
  12.  omnicontacts
  13.  rails-i18n
  14.  devise-i18n
  15.  stripe
Application demo: https://saas.corsego.com/

22 chapters
177 lessons

Chapter 1. Introduction
2 lessons
1. Preview of the final application
2. START HERE
Chapter 2. Create the application
7 lessons
1. create aws cloud9 ide for ruby on rails
2. create app and configure postgresql
3. push application to github
4. clean up gemfile
5. home index view
6. install bootstrap
7. push application to heroku
Chapter 3. Authentication with devise
5 lessons
1. gem devise
3
2. bootstrap navbar on steroids
3. bootstrap for flash messages
4. users index and show
5. user can see home index without being logged in
Chapter 4. Tenants and Members
8 lessons
1. database design for tenants and members
2
2. gem simple_form
3. scaffold tenants
4
4. tenants styling and validation
5. scaffold members
6. user-member-tenant relationships
7. when a tenant is created, the creator becomes a member
8. my tenants scope - user sees only his tenants
Chapter 5. Devise invitable - invite new users via email
4 lessons
1. gem devise_invitable
2. user can invite other users to become members of a tenant via email
1
3. if the user has not accepted the invitation, he can be re-invited
1
4. see by whom a user was invited
Chapter 6. Multitenancy with gem acts_as_tenant
22 lessons
1. gem acts_as_tenant - get current_tenant, scope members by tenant
2. remove tenant from strong params in members, because acts_as_tenant sets it automatically
3. fix header to work without current_tenant, members - remove create and new actions
1
4. add_tenant_id_to_users
1
5. button for user to switch between tenants where he is a member
6. tenant has to be set to access scoped models
7. make require_tenant logic reusable - move it to controllers concern
8. when a tenant is created set it as current_tenant for the creator
9. style header dropdown for tenants
10. members_controller invite - validate if email was provided (devise invitable)
11. MemberMailer - send email when existing user was invited to tenant (devise invitable)
12. bootstrap styling for new, edit, show views
13. security - set_tenant only if current_user is member in tenant
3
14. move logic for setting a tenant to a set_tenant concern
4
15. try setting tenant only for specific controllers
16. global and tenant-specific views
1
17. destroying a tenant, resend invitation in members index
18. set current_tenant by url
19. current_tenant for static dashboard page
20. separate controllers for tenanted and not tenanted static pages
21. separate navigation for current_tenant links
22. rails includes method - faster relationship loading
Chapter 7. Basic styling
11 lessons
1. sidebar basic styling
2. responsive tables
3. custom navbar color
4. shadows give depth
5. meta tags - mobile responsiveness
6. static pages (about, terms, privacy, pricing), basic footer
7. stylesheet_pack_tag replaces stylesheet_link_tag
8. install fontawesome, add icons for navigation
9. basic content for static pages, footer styling
10. footer always on bottom
11. counter_cache (members_count column in users table)
Chapter 8. Authorization - user roles
10 lessons
1. add roles to members with rails hash
2. role-based authorization for specific controller actions
3. set current_member
4. only admin member can edit, update, delete current_tenant
1
5. only tenant member can access tenant show action
6. view validation for tenant authorization
7. when a user creates a tenant, he becomes an admin
8. default role for member created by invite
9. a member must have at least one role
10. there has to be at least one admin member in a tenant
Chapter 9. Adding a new scoped model
6 lessons
1. scaffold Contacts
2. basic validation for Contacts
3. add multitenancy scope to Contacts
4
4. concern for current_member, role-based restrictions for Contacts
5. basic styling for Contacts (no video)
6. tenant has_many contacts dependent destroy
Chapter 10. Creating advanced custom controllers, friendly URLs
3 lessons
1. public page to set current_tenant without current_user
2. displaying nested resources
3. path to create Contact for current_tenant without current_user
2
Chapter 11. Working with URLs
6 lessons
1. friendly URLs for Tenants
2. link to external web form for lead creation
3. update friendly URL if tenant name changes
4. reserved tenant URL names (tenant name validation)
5. shortening URL for web form for lead creation
6. friendly URLs for users and members
Chapter 12. Plan-based tenant restrictions
2 lessons
1. add plan to tenants
2
2. tenant with solo plan can not invite members
Chapter 13. Bonus 1: Image processing with ActiveStorage and AWS S3: Add logo to tenant
5 lessons
1. Add basic logo and favicon to application
2. Install ActiveStorage and add logo to Tenants
3. ActiveStorage validations - validate tenant logo type and size
2
4. ActiveStorage and AWS S3 - store application files in the cloud
5. Rails Secret Credentials
Chapter 14. Bonus 2: Preparing for Production
8 lessons
1. devise confirmable - no fake users
2. send emails in production with Sendgrid
1
3. gem exception_notification - catch errors in production
4. invisible recaptcha on sign_up - no bot emails
5. styling devise views
6. devise trackable
7. connect a real domain name (namecheap and heroku)
8. Add seeds (demo data)
Chapter 15. Bonus 3: Advanced oAuth (connect multiple social accounts)
12 lessons
1. gem omniauth-google-oauth2 - log in with google
2. gem omniauth-github - log in with github
3. different credentials for different environments
4. understanding the omniauth code
5. save data from omniauth requests
6. clean up omniauth controller
7. display omniauth data in user profile
8. p1 connect multiple oAuth providers to one user (migration, relationships)
9. p2 connect multiple oAuth providers to one user (refactoring controller)
10. p3 connect multiple oAuth providers to one user (create user in controller)
11. p4 connect multiple oAuth providers to one user (connect identities)
12. p5 clean up and finalize oAuth views
Chapter 16. Bonus 4: internationalization (i18n)
14 lessons
1. add locales
2. select language for session
3. translate navbar header (deep translation path)
4. Translations for Active Record Models (tenant name, logo)
5. validate available locales
6. styling dropdown to select language
7. styling bootstrap dropdown css
8. gem rails-i18n
9. gem devise-i18n
10. Translating views (index, show, new, edit)
11. Translating controllers and custom text
12. set locale from user settings
13. clean up application_controller - set_locale concern
14. redirect to previous page OR root
Chapter 17. Superadmin views
15 lessons
1. add superadmin boolean to users
2. routes - superadmin namespace
3. git - undo last commit while saving history
4. routes - superadmin scope (alternative to namespace)
5. only superadmins can see users index (controller)
6. helper method to style boolean values
7. user show action - superadmin can see any user, simple user sees only himself
8. routes-based devise current_user authorization
9. navbar styling - conditional superadmin links, refactor controllers
10. try to add superadmin in seeds
11. unscope user resend_invitation action
12. superadmin view for tenants index - via controller
13. troubleshooting superadmin path for tenants
14. remove unused before_action require_superadmin
15. superadmin dashboard
Chapter 18. Bonus 5: Omnicontacts - import contacts from google users
4 lessons
1. gem omnicontacts - import google contacts into Rails app
2. persist contacts imported via omnicontacts
3. improve contacts import mechanics
4. skipping validations when importing contacts
Chapter 19. Plans and Subscriptions
22 lessons
1. create plans
2. create subscriptions
3. access tenanted controllers only with subscription
4. button to subscribe to a plan
5. access tenanted controllers only with ACTIVE subscription
6. show current subscription data in tenant show
7. access tenanted controllers only with ACTIVE subscription (fix)
8. create charges
9. link to create charge and resume subscription
10. tenant show - display all charges
11. clean up subscriptions and charges (controllers, views, routes)
12. can't create 2 subscriptions to 1 tenant
13. subscription-based restrictions (max_members)
14. cancel (destroy) subscription without destroying dependent charges
15. Serialize Metadata for Charges
3
16. superadmin views for subscriptions and charges
17. superadmin views for plans, dynamic public pricing page
18. conditions for destroying plans, tenants, subscriptions
19. ActsAsTenant for subscriptions
20. RequireSubscription concern
21. ActsAsTenant for charges. Rename RequireSubscription to RequireActiveSubscription
22. validation - You feature comsumption exceeds this plan. Please select a bigger plan
Chapter 20. Payments with Stripe
1 lesson
1. payments with stripe
Chapter 21. Cool Features, Fixes, Adjustments
6 lessons
1. AWS - no space left on device - add 20 gb storage
2. Devise - redirect to specific page after sign in
3. Security: anybody on the web can scrape your leads
4. active_link_to helper
5. rename home_controller to tenant_controller
6. connect custom domain, upgrade heroku paid account, configure ssl
Chapter 22. Thank you and next steps
4 lessons
1. Final ERD, Deploying the final application from the source code
2. Next Steps
3. Thank You
4. Useful links (multitenancy articles)

2 reviews

LOVE IT

It's quite a complete tutorial and can be used as a practical guideline.