# Controllers, models and views in plugins

**URL:** <https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217>\
**Category:** Rails\
**Created:** [March 13, 2006, 8:21am UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217 "2006-03-13T08:21:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![coldtone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@coldtone](https://www.ruby-forum.com/u/coldtone)\
**Post date:** [March 13, 2006, 8:21am UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217/1 "2006-03-13T08:21:34Z")

</div>

Hello all,

Is it possible to package controllers, models and views in a plugin?  
The  
tutorials for plugins seem rather sparse at the moment…

I’ve written a form “widget” that I’ve been using as a partial that I  
would  
like to reuse in other projects. I was thinking about making a  
component  
out of it, but I need to be able to access some of the form data that it  
saves in my application’s models, so that wouldn’t work. I suppose that  
it  
would be possible to do all of the display as a component and then write  
a  
plugin that just the models of my app can interact with to get the data,  
but  
this doesn’t seem like the most elegant of solutions.

So to sum it up I’m hoping that it is possible for mvc’s to be used  
within  
plugins so I can package form widget as one. I’d greatly appreciate it  
if  
somebody would point me in the right direction.

Thanks for the help,

Rob

---

<div class="post-metadata">

**Author:** ![coldtone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@coldtone](https://www.ruby-forum.com/u/coldtone)\
**Post date:** [March 13, 2006, 8:24am UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217/2 "2006-03-13T08:24:43Z")

</div>

Check out  
[http://www.rails-engines.org/wiki/pages/Components+vs.+Plugins+vs.+Engines](http://www.rails-engines.org/wiki/pages/Components+vs.+Plugins+vs.+Engines)  
for some info.

Pat

---

<div class="post-metadata">

**Author:** ![coldtone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@coldtone](https://www.ruby-forum.com/u/coldtone)\
**Post date:** [March 13, 2006, 4:09pm UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217/3 "2006-03-13T16:09:59Z")

</div>

Thanks for the link Pat. I read through it and it seems like what I  
need is  
a cross between a component and a plugin. I’ve noticed that the user  
engine  
has app/controllers,models,etc… that can be used application wide, but  
I’m  
not sure if these MVC’s are something specific to engines or if a normal  
plugin can have the app/controllers, etc. Anybody have any ideas if the  
same can be done with plugins?

Rob

---

<div class="post-metadata">

**Author:** ![coldtone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@coldtone](https://www.ruby-forum.com/u/coldtone)\
**Post date:** [March 13, 2006, 5:02pm UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217/4 "2006-03-13T17:02:04Z")

</div>

In a nutshell, the engines plugin enhances the plugin system to  
provide the kind of functionality that you seem to want, and the  
engines plugin _only_ exists because it’s not possible to achieve this  
with the vanilla Rails plugin mechanism.

An “engine” really IS a plugin, with a few minor differences (that  
most significant being the replacement of init.rb with init\_engine.rb)  
that enable loading views, controllers and models (and other stuff:  
public assets, migrations, tests) from within them. That’s basically  
all it’s for.

- james

On 3/13/06, Rob M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 3/13/06, Pat M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > >
> 
> it
> 
> > > somebody would point me in the right direction.
> 
> “Do not meddle in the affairs of dragons, for you are crunchy and good  
> with ketchup.”
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

- J \*  
~

---

<div class="post-metadata">

**Author:** ![coldtone](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/9e8a1a/32.png) [@coldtone](https://www.ruby-forum.com/u/coldtone)\
**Post date:** [March 13, 2006, 6:37pm UTC](https://www.ruby-forum.com/t/controllers-models-and-views-in-plugins/80217/5 "2006-03-13T18:37:47Z")

</div>

Thanks for the help James, I’ll poke around the engines and see what I  
can  
come up with.

Rob
