Controllers, models and views in plugins


#1

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


#2

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

Pat


#3

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


#4

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 wrote:

On 3/13/06, Pat M. 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

  • J *
    ~

#5

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

Rob