0

Let's say you build a simple blog system.

Instead of having to publish this blog system across 3 different Heroku dynos which would be expensive for something so simple (requiring at least 2 dynos each so it wouldn't idle)... there's the option of possibly splitting the logic of 3 different domains on one app.

How would you take the logic and data currently in place for one instance of the app, and then split it up so 3 different domains can use the data scoped to that domain? This is taking existing data to form this system.

Sorry if this wasn't clear enough.

1 Answer 1

1

Point all three domains at the same app.

You will need to create a domain model to handle this.

class Domain < ActiveRecord::Base
  has_many :blogs
  belongs_to :admin
  validates_uniqueness_of :domain_string
end

class ApplicationController < ActionController::Base

   before_filter :get_domain


   def get_domain
      @domain = Domain.find_by_domain_string(request.host)
   end

end

class BlogController < ApplicationController

   def index
      @blogs = @domain.blogs.whatever_additional_logic_you_need
   end

end

Everything else would follow about the same pattern.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.