How can I abstract the core functionality of multiple Rails applications?

I would like to develop a number of non-trivial Rails applications that implement a core set of functionality, but each has certain customizations, extensions, and aesthetic differences. How can I pull out the core functionality (models, controllers, helpers, support classes, tests) common to all of these systems, in such a way that a kernel update will benefit every application based on it?

I've seen Rails Engines, but they seem too detached, almost too abstract to be used. I might think they are useful for adding a single component to an existing application, such as linking a blog engine to an existing e-commerce site. Since the engines appear to be mostly self-contained, it seems difficult and awkward to override their functionality and views while maintaining DRY.

I've also considered abstracting the code into a gem, but that seems a little odd. Am I making the gem depend on the Rails gems and also define models and controllers within it and then subclass them across different applications? Or can I define many modules within a gem that I include in different locations within my different applications? How do I test a gem and then test a preset and overridden functions on top of it? I also care about how I will develop gem and Rails applications in tandem, can I create a git gem repository in the application and push away from it so I don't have to create a new gem every iteration? Also, are there private gems / can I establish my own gem source?

Also, any general suggestions for this kind of commitment? Abstraction paradigms adhere to? Reading required? Comments from the wise who have done this before? Thanks!

+2


a source to share


1 answer


Never done this, but I think a Rails plugin would be suitable for it:

http://guides.rubyonrails.org/plugins.html#models

http://guides.rubyonrails.org/plugins.html#controllers



http://guides.rubyonrails.org/plugins.html#helpers

And afterwards you can create a gem:

http://guides.rubyonrails.org/plugins.html#plugingems

+1


a source







All Articles