As it stands now, you can't reopen Engine classes contained within the engine's /app
directory by simply adding the same class in the parent app's /app
dir. For example:
/my_engine/app/controllers/users_controller.rb
/my_app/app/controllers/users_controller.rb
The file from my_engine
will not even load if there is a file with the same name in the parent app. More details here:
I am looking for a workaround that will allow me to drop the same filename/class in the same path as the parent app, and reopen instead of overwrite the class. Maybe I am missing something obvious. I am able to make this work with a separate file (different filename) that uses class_eval, but I am not really happy with that solution. Any ideas on an elegant solution for this?
I am also wondering if there is a reason behind this restriction, or is it just a result of how rails loads files (see included link) and not intentional. It seems to me that changing the load behavior of engines to allow reopening classes in this manner would be a good feature in rails. I know it confused me at first, and I am sure other developers will struggle with this problem as well.