Ruby on Rails Monday, November 17, 2014

Hi Kyle and Frederick,

I have a point of view I would like to share.

I have developed an application in rails for the 1 year and a half with more than 6 different engines. He have been through this problem too many times and our conclusion was very simple. We had to create a Core engine where he had all the shared code but also almost all our models. There was a lot of reasons for doing so:

1. Almost all our models have relations in between them, so they should not be separate in different engines, they will always depend on each other. applying this to your example: If there is an author on blog, most likely there will be some methods inside that blog that will use the author for something.

2. Then Core will act like a gem, where all the other engines that should have separate and independent code, will just install. So your blog engine will always be dependent on the core gem, but its such a basic dependency as we all depend on Active Record.

3. The tests will be simple and easier to do. The solution presented by Frederick is not so good as: 1. Your dummy app will be dependent on having a class called author, so should be every other app that uses your engine. So what's the point on doing a engine if they will have dependencies in between them? 2. You should never commit the dummy app code.

Maybe this is not the most correct approach to your problem. But its an idea you can use.

Just one more comment. I can see you have written this in your problem: "The engine can then simply make use of whatever account scheme is in use in the main application.", this is almost impossible to achieve, because you dont know what the author is. You either pretend there is no author at all and the main app developer decides what to call and what to you use. Or you give 1,2 or 3 different alternatives. 

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d1df3458-edf8-4d8b-9a14-872399377737%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment