Multi tenant/lang application with Ruby on Rails

50 %
50 %
Information about Multi tenant/lang application with Ruby on Rails

Published on March 4, 2014

Author: happynoff



Slides of my "Multi tenant/lang application" at Paris.rb on 2014-03-04.

Multi tenant/lang application Simon Courtois - @happynoff

Multi-tenant you say? APP

APP middleware switcher Website

Website domain lang class Website < ActiveRecord::Base def self.current Thread.current[:website] end ! def self.current=(website) Thread.current[:website] = website end end Website.current = Website.first ! Website.current # => #<Website domain=“" lang="en">

APP middleware switcher ✔ Website Website

switcher class WebsiteSwitcher attr_reader :domain, :host, :website ! ! ! ! def initialize(host) @host = host.downcase.chomp('.') end def domain @domain ||= ActionDispatch::Http::URL.extract_domain(host) end def website @website ||= Website.where(domain: domain).first || Website.where(domain: '') end def switch! Website.current = website I18n.locale = website.lang end end'').switch!

APP middleware ✔ switcher switcher ✔ Website

middleware require 'website_switcher' ! class WebsiteSwitcherMiddleware def initialize(app) @app = app end ! ! ! def call(env) request =! end end

APP ✔ middleware middleware ✔ switcher ✔ Website

require 'middlewares/website_switcher_middleware' ! APP module AwesomeApp class Application < Rails::Application # ... ! config.middleware.use WebsiteSwitcherMiddleware end end

✔ APP APP ✔ middleware ✔ switcher ✔ Website

Questions ?

Thank you Simon Courtois - @happynoff

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Ruby on Rails

Learning to build a modern web application is daunting. Ruby on Rails makes it much easier and more fun. ... Ruby on Rails is open source software, ...
Read more

Multitenancy with Rails by Ryan Bigg [Leanpub PDF/iPad/Kindle]

Multitenancy with Rails ... tricks about Rails and PostgreSQL while you build a multi-tenanted Ruby on Rails application. What's a multi-tenanted ...
Read more

Multi-tenant rails application: what are the pros and cons ...

I originally wrote my Ruby on Rails application for one client. ... Any advice related to multi-tenant applications or my situation is welcome.
Read more

multi tenant - CDN for a multitenant Ruby on Rails ...

I have created a multitenant Ruby on Rails application. Each tenant will configure their domain name to my server's ip and then they can navigate to their ...
Read more

Getting Started with Rails — Ruby on Rails Guides

Getting Started with Rails. ... Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, ...
Read more

The Ruby Toolbox - Multitenancy

The Ruby Toolbox is a comprehensive catalog of Ruby and Rails plug-ins, ... Rails multitenancy with ... Integrates multi-tenancy into Rail application with ...
Read more

Create a multi-tenant SAAS app with Ruby on Rails

Office Productivity. Office Productivity. Microsoft; Apple; Google; SAP; Intuit ... Personal Development
Read more

Multi Tenant SAAS application in Ruby on Rails - Ashwin ...

Creating a SAAS application in Ruby on Rails is ... I have documented the whole process in a course called Creating a multi tenant SAAS app in Ruby on Rails.
Read more

Form Helpers — Ruby on Rails Guides

Form Helpers. Forms in web applications are an essential ... The previous sections did not use the Rails form helpers at ... "Ruby on Rails", ...
Read more