Running rails app both as engine and app

37 views Asked by At

I'm transforming a Rails application (say appA) into engine so that I can hook it into another Rails app (say appB). However appA must run as a Rails app solely as well. That's because a customer can buy

  1. appA or
  2. appB with appA. There is no option of buying only appB.

Following rails oficial guide I made (among others) following changes:

  • Changed Rails.application.routes.draw to ActionPlan::Engine.routes.draw in routes.rb.
  • Created lib/action_plan/engine.rb with content shown below:

    module ActionPlan
      class Engine < ::Rails::Engine
        isolate_namespace ActionPlan
      end
    end
    

Now when I run rails s I get /action_plan/config/routes.rb:1:in '<top (required)>': uninitialized constant ActionPlan::Engine (NameError).

I guess I should initialize ActionPlan::Engine in application.rb file somehow but I don't know how neither whether it's the way to go.

So is it possible to build an app/engine in rails such as appA? If it is, how can I overcome that problem?

1

There are 1 answers

0
Cristiano Mendonça On BEST ANSWER

After some researching and talking to some friends, I found out that it's not possible to do such a think with rails, but it's possible you to create another rails app (say appC) and use it only to run your engine, i.e appC is a silly rails app used only to make it possible to run your engine.