Routes?

Any tips on adding plugin specific routes? I’d like to add them directly
in
my plugin if possible.

Check the documentation for the #from_plugin addition to routing…

I had a chance to look at that last night, but still I find myself
wondering
why I am not able to directly tie into the routes, automatically.

I’d like to not have to require any installation steps for routes if
possible. Any recommendations? Such as having a conf option in my plugin
to
say that all engine routes go first, then use the application routes.
Didn’t
sound like this was possible reading the specs… but advice on how to
get it
to work this way would be awesome.

Indeed it’s not possible as things stand, and that’s by design. It
would be impossible for a plugin writer to know, for certain and in
advance, what priority the routes he/she wishes to contribute should
have.

The point of plugins, IMHO, is not for them to be “plug and play”.
They should simply provide a piece of functionality which is easier to
use than it would be for the developer to write and test themselves.
The end user - who is a developer themselves - still ought to take
responsibility for how their application uses that functionality. In
this case, it’s my feeling that this means they should know where best
to put your plugins routes.

That said, if you’re hell-bent on having your plugin’s routes
automagically injected, you probably need to starting hacking around
with the ActionController::Routing::Routes.draw method. Perhaps you
might use alias_method_chain to wrap it in a method that adds the
routes for your own plugin.

  • James