abraham icon indicating copy to clipboard operation
abraham copied to clipboard

Namespacing and isolating engine. Include documentation to mount and …

Open adriancb opened this issue 3 years ago • 2 comments

An issue we discovered while integrating Abraham that could be rather common is that routes from integrated engines are appended to the app routes.

We have a catch-all route as the final directive that means routes appended via Rails.application.routes.draw become unreachable. In this instance the /abraham_histories route was unreachable.

This PR attempts to isolate and namespace Abraham so that it can be mounted separately.

Given the additional mounting requirement, the suggestion is that a major version is released.

adriancb avatar Jun 28 '21 11:06 adriancb

@adriancb Thanks so much! This seems like a responsible thing to do, and all the tests pass :) I'll review with our team.

A couple questions:

  • Since this is the only Rails engine I've developed, I'm curious to know how other engines handle this. Do you have a handy example to share?
  • You've upgraded the Ruby version — does this change require it, or is it only incidental? I ask because it suggests to me that our continuous integration may want to test not only multiple Rails versions but also multiple Ruby versions.

jabbett avatar Jun 29 '21 15:06 jabbett

👋 @jabbett; thanks for the feedback - great!

In terms of examples, a couple of examples (of libraries we use) spring to mind:

  • https://github.com/voormedia/flipflop/blob/master/lib/flipflop/engine.rb
  • https://github.com/splitrb/split/blob/main/lib/split/engine.rb

I believe that at its core, an engine is just a Rack app, it could be Sinatra as per below:

  • https://github.com/RailsEventStore/rails_event_store/blob/master/ruby_event_store-browser/lib/ruby_event_store/browser/app.rb

Hope that helps! 😄

In terms of the upgraded Ruby version; this change does not require 2.7.x and neither does Abraham, but thought it was good practice to bump to the latest minor version. I'm unsure you need to support multiple Ruby versions. Happy to yank the change if it causes confusion/etc.

adriancb avatar Jun 30 '21 01:06 adriancb