Developing Engines within a parent application

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Developing Engines within a parent application

Walter Lee Davis
I'm working on my first project involving Rails Engines, and there's some kind of disconnect for me between the Rails Guides and what is happening in my application. There are several references in the guides to an /engines directory in the parent application, yet when I put my engine (under development) in that hierarchy within the parent application, any migrations or models or controllers I try to generate later (by navigating into [parent app]/engines/my_engine and running the relevant rake or rails command there) ends up being executed by the parent app, and the files end up in the parent app as well.

As a test, I just followed the directions in the Guide, but built my engine as a separate Rails app, outside of any parent app, so I now have /sites/my_engine and sites/parent_app side by side. (The gem is added with the path: ../my_engine) This seems to work much better -- when I run the generators in the engine, their output is confined to that engine. And then, when I use the rake my_engine:install:migrations task, the new migrations are properly copied out into the parent app, and can be run there.

This is more of what I was expecting, because the canonical examples (Devise, Forem, etc.) are all run that way -- views, controllers, and models all live in the gem/engine and any migrations needed are installed in the parent app during gem installation and run there.

But none of this then leaves me with an /engines directory, unless I'm missing something.

Could someone who has done this sort of thing before point me to what I'm doing to diverge from the path?

Is it as stupid as me needing to prefix the rails or rake command with ./bin/ so it's painfully obvious *which* rails I mean? Or is it a case of the docs lagging behind the actual code? I'm using Rails 5.1 for this (and following the 5.1 version of the Guides) if that's another point of difference.

Walter

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/F29EA345-3862-42D9-A7B8-BCB2B42DC4D9%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.