rails engines and models

38 views
Skip to first unread message

jsnark

unread,
Dec 30, 2013, 9:12:42 AM12/30/13
to rubyonra...@googlegroups.com
I have several rails applications that I want to combine into a single application using rails engines.  Many of the models appear in multiple applications (now engines) and have some methods in common.  I want to make this code DRY, removing the code duplication that I now have.  Ideally, I want a single instance of the common methods and still be able to test each engine independently.  Where should I put the common methods?

Some pointers would be appreciated.

Josh Jibwa White

unread,
Jan 1, 2014, 1:50:17 PM1/1/14
to rubyonra...@googlegroups.com
I think the best solution would be to create a engine or gem for the shared classes. 

Say you have a user model which has shared functions and application specific functions. I would put the base (shared) functionality into a base engine which is included in the feature engines. In each feature engine I would extend or add functionality to the the user class.

It seems a little like overkill if you are just extending one class, but if you have a set of shared features that other apps build on it would be a good approach to make dry and reusable. 
Reply all
Reply to author
Forward
0 new messages