Hi, I would like to plug in certain functionality with an engine and I have done it in different ways in different projects and would really like to understand how you are approaching this problem. An engine provides additional controller, views, models - how do you plug in links to this additional controllers in existing views.
I have an ‘organizations’ engine that provides
# in the 'organization' engine class Organization < ApplicationRecord end
There are controllers, models, views
One client needs to have a relationship (parent-children) between the organizations. This is not needed by other clients. Naturally we create an engine - 'organizations_relations" that provides the model, controllers, views for creating and managing relations and we would pack this only for this client.
# in the 'organizations_relations' engine class OrganizationRelation < ApplicationRecord end ... # and models, views, controllers.
But now that there is the ‘organizations_relations’ engine we should put an extra link in the organizations/show.html.erb that points to /organizations_relations.
But organizations/show.html.erb is in the ‘organizations’ gem that knows nothing about the ‘organizations_relations’.
How do you plug in the link to /organizations_relations from the ‘organizations_engines’ into the organizations/show.html.erb available in ‘organizations’ engine.
- Do not do it and put the link somewhere else, but not on the organizations/show.html.erb
- Use deface gem or similar mechanism for extending views
- Rewrite the organizations/show.html.erb in the ‘organizations_relations’ engine
- Rewrite the organizations/show.html.erb in the host app.
- Something different?
- Do not do it at all because it is the wrong approach - engines are not meant to be extended…