B
B
bismoney2015-11-10 13:16:31
Ruby on Rails
bismoney, 2015-11-10 13:16:31

Rails multisite?

Tell me something travel, maybe a link or a guide.
I've looked all over, very little information.
I would like to have one admin panel for several sites, different databases, views

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vsuhachev, 2015-11-10
@bismoney

First, learn to ask questions. What is "multisite"? Google does not google anything intelligible for this word.
On this topic:
different bases - it is theoretically possible, but practically inconvenient (and has no special advantages). With different databases, your application must have advanced rights to create these databases, create users and grant them rights. Assuming that the tables in each database will be different, then how will the overall application code work with this?
Therefore, it is easier to have one pre-created database with a universal table structure, each table has a site_id column and filter all data by this column.
Different views - this is done quite simply with the help of prepend_view_path

class ApplicationController < ActionController::Base
  before_action :detect_site

  def detect_site
    @current_site = Site.find_by(host: request.host)
    prepend_view_path "app/views/sites/#{@current_site.name}"
  end

  helper :current_site
end

If you want to store templates in a database, take a look at panoramic

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question