A single-user multi-user application across domains in Rails?

I need to develop a multi-node application with a single sign in different domains (something like a google account with several google services like gmail, docs, google +):

multi applications, multi domains, single sign on

  • To use affiliate sites, the user must register with the parent site.
  • Each site has its own logic, except for user input, points and invoices.
  • From a child application, I should be able to log into a global user account, spend user points and generate an invoice for some services.
  • Registration form, list of invoices and panel for managing points available only from the parent site / application.

What is the best strategy to implement this in Rails 3.1? Scalability, performance and security are important.

  • Applications with one or more rails?
  • Single or multiple databases
  • Global services in the main application or as separate applications / engines?
  • How to implement single sign-on? One session id in the database or something like facebook oauth?
  • How to implement expense items and generate invoices as a result of a request from a subsidiary site?
+6
source share
2 answers

So, let's say you create a Model User in the main application and transfer it. Then you need to access this Datbase from other applications. It's not a problem. First you need to add the definition of the base connection of the main application to the config/database.yml child application as follows:

 parent_connection: adapter: your_adapter_here host: your_host_here username: username password: password database: main_application_production 

Then you create a model called "User", but not with scaffolder or sth. like this. Just create a file like this:

 class User < ActiveRecord::Base establish_connection :parent_connection # This uses the specified connection end 

In the default case, the selected connection is the same as the environment name. You only need to specify options. So, now you can access the User class, as in the main application.

-1
source

Source: https://habr.com/ru/post/903764/


All Articles