# Engines vs plugins

**URL:** <https://www.ruby-forum.com/t/engines-vs-plugins/111321>\
**Category:** Engines\
**Created:** [August 5, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/engines-vs-plugins/111321 "2007-08-05T23:43:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![d3ntaku2](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/ce73a5/32.png) [@d3ntaku2](https://www.ruby-forum.com/u/d3ntaku2)\
**Post date:** [August 5, 2007, 11:43pm UTC](https://www.ruby-forum.com/t/engines-vs-plugins/111321/1 "2007-08-05T23:43:55Z")

</div>

hi engineers…

we’re just planning whether to use engines or build something around  
plugins, interested to know what success others are having.

“engines” seem to allow most of what i need, but they dont seem to be  
getting much use.  
they depend lot of rails internals, and it seems they aren’t the safest  
way to go

- every time rails changes, all engines break. if the core developer  
stopped maintaining engines, i doubt we’d be able to go in and keep  
things working…  
is there much momentum behind plug-ins?

when components come back as a plug (rails2) will this conflict with the  
work on engines?

------ reusable code in rails

Like many other companies I’m sure, we have a bunch of rails code for  
building social networks. and we’re doing lots of projects that are very  
similar.

i was wondering what rails options have been succesful for other  
people for code re-use across projects.

my understanding is that plugins’ approach to anything  
with views is to use generators.  
you cant actually have view/controller code in the plugin?

the problem with generators is that then you cant re-use any  
modifications to the generated code - theyre basically one-way.  
but this maybe OK, if a lot of the actual code is still in the plugin.

- concrete example: forum  
a good specific thing we need to do: a forums  
if we move this into a plugin…

- dependencies on main app / models  
first, there are dependencies on the main app’s user model.

- migrations  
there arent easy way to share migrations with the main app and an also  
evolving plugin.  
this could possibly be solved in the plug-in installer having its own  
mini-migrations.

- getting added code back into plugin  
but, lets say we add a function to the forum. eg we want to show the  
“status” of any poster.  
eg are they a level1, or level5 person.  
this is basically a modify of the view, plus reading some data from  
the user model: user.status  
not much controller code.

if we modify the BBS view after the code was generated,  
then no code goes back into the plugin for re-use/sharing.  
a generator is basically one-way.

- view helpers?  
since plugins support -view helpers- we could rewrite the forum views  
all as helper methods.  
these could then maybe be passed parameters? eg render\_forum  
(:with\_status) would be in the generated view for the app.

- installing partials  
another thing some people seem to do is have the installer copy some  
partials into the main app.  
this is just as set in stone as generators really. eg:  
[http://svn.nanorails.com/plugins/bookmarkit/install.rb](http://svn.nanorails.com/plugins/bookmarkit/install.rb)

- can a plugin include a controller?  
i guess it could include a library, which is a module that the  
controller in the app could require…

- non abstract plugins  
basically for abstract functions (like a swf renderer, or AR/ acts\_as  
extensions) the plugin approach works well.  
but not sure how much it will save us on these very view-oriented  
items.  
it may end up being a lot of work to make the plugin, and then its  
basically just a fancy way to cut and paste the code.  
how much code will actually be in the plugin, vs. what is generated?

i think this is a problem for rails. now components are in limbo, there  
isnt an obvious way to reuse/subclass view-related functionality.

given above caveats about engines, not sure what is the best approach.

Any thoughts appreciated.

/dc
