0

I'm currently developing a Rails application which will be extended by several Engines.

These Engines can be developed by other developers and will be mounted in the main application.

The problem is, that I'm not allowed to update the Relationships between existing and new models.

To make it more clear, let's assume that I have a User-Model (in the User-Engine) and a comment-Model (in the Comment-Engine). The Comment-Model has defined the relationships to the User-Model, but the User-Model is untouchable (the relationship to the new comment-Model can't be added, because the User-Model was developed long time before the new comment-Model)...

I just want to hear some of your thoughts on solving this problem (one of the main issues is the lack of dependent: :destroy-actions).

I've heard, that a relationship-Engine would be a possible solution (where the relationships will be declared)...

What do you think about this issue?

tshepang
  • 12,111
  • 21
  • 91
  • 136
pmuens
  • 788
  • 6
  • 16
  • Wouldn't Ruby's dependency injection come in handy here? Meaning, that the Comment-Engine could simply add the relation (or redefine it) when being mounted? I've never worked with engines, but I'd assume that this kind of behavior would be possible. Probably through the `main_app` object!? – Vapire Sep 28 '13 at 23:04
  • Thank you for your comment! I've solved this issue with a decorator. See this link for an explanation: http://stackoverflow.com/questions/18451915/rails-gem-with-model-relationships-for-rails-engines – pmuens Sep 30 '13 at 17:07

0 Answers0