Rails engine with own DB

14 views
Skip to first unread message

Tomas Valent

unread,
Mar 2, 2018, 7:02:57 AM3/2/18
to Ruby on Rails: Talk
I was wondering if there is a way how to do Rails Engines (as bound contexts) where each engine would have it's own (ActiveRecord) database. 


Imagine every bound context (Rails engine) would have own DB (like microservices has) 

Online store app
  * product listing - own postgres DB
  * orders  - own postgres DB
  * basket - own postgres DB


I know that this could teoretically be done on model level:

module YourEngine
  class Post < ActiveRecord::Base
    establish_connection :adapter => 'sqlite3', :database => 'db/your_engine.sqlite3'
  end
end


But is there anything like `my_engine/config/database.yml`  ==> own ActiveRecord database setup for every engine ? 

I'm purely just investigating the possibilities for a talk don't really want to implement something like that

Thank you
Reply all
Reply to author
Forward
0 new messages