echan00
echan00

Reputation: 2807

How do I mount multiple rails engines?

What should I do if I want to be able to host multiple instances of the same rails engine (bot)? This will be separate engines (using the same code) but using different model attributes, data, etc..

The only way that makes sense to me is to mount separate engine (bots) doing something like this..

mount SomeENGINE, at: 'bot/:unique_id'

Is this the way to do it? Basically having a separate web-hook per engine as a way to identify each of them?

Upvotes: 0

Views: 957

Answers (1)

Sean Huber
Sean Huber

Reputation: 3985

Yeah your idea will basically work. Here's an example for mounting the enginge 10 times at 10 different routes:

Rails.application.routes.draw do
  (1..10).each do |idx|
    mount MyEngine::Engine => "/bot_#{idx}"
  end
end

Upvotes: 1

Related Questions