views:

308

answers:

3

I would like to know if there is a good plugin for rendering navigation links in Rails. It would be nice if it could render links to all possible GET actions on a controller directly from the routes file.

A: 

Can I ask the purpose of your question? There are only four get actions in a RESTful controller, (index, show, edit, and new). The overhead in producing a list using a special route generator on the fly is probably too much.

You could simply create a partial that can render those four actions for whatever controller you're currently viewing (think params[:controller]).

As far as for all possible Get actions: All possible get actions would encompass the show action for each item in your database. That is, again, best handled in a partial and the use of link_to.

It's hard to give a complete answer though, because your circumstances seem unique.

I hope this helps even a little.

-Chris

Christopher Hazlett
a restful controller can have n number of actions, it's only rails convention that enumerate the 4 actions you mentioned. some resources require more representations. I.E.map.resources :elements, :member => [:summary, :dots, :issues, :link_to_irma_organizations, :lists, :manage_permissions, :users]
Chris Drappier
So, my current method of link rendering is a yml configuration file that enumerates the links to the get actions for each controller, this can very easily get out of sync with the available routes because it has to be manually edited. I'd much rather load the menu configuration from the routes.
Chris Drappier
Sorry. Didn't realize you commented. I hear what you're saying, the standard configuration probably mandates that you separate your concerns. you've got a manage_permissions and a users method for a controller. Seems like you need to split your controller up into more distinct concerns.
Christopher Hazlett
Also, using YAML as a configuration method for your menu is probably a bad idea. YAML is not going to scale well. If you're putting data into a YAML file, you might just consider building a menu model and loading that on each call. MySQL will outperform YAML in the long run.
Christopher Hazlett
The yaml file is loaded into a constant when the application is loaded,I could do the same with the database, i guess, but it's really nice to have all the configuration in a file that can be changed quickly
Chris Drappier
the actions in the route configuration do nothing but render templates from the views directory. the links and forms inside those templates are routed to their proper controller.
Chris Drappier
It's a tough call, but I like storing menus in the database. That way I don't have to restart the WS if I change the menu structure...additionally, if you want to expose (or hide) menus according to a permission structure, that's easily accomplished with a db...and the logic is changed very easily.
Christopher Hazlett
A: 

While this does not answer ths specific question, you can see all of your OWN routes on the command line by running

rake routes

This will give you your own personal readout of all of your routes on the site, however like Chris said above, this isn't really a specific answer, more of an FYI.

Cheers!

BushyMark
A: 

You should try Mmmenu: http://github.com/snitko/mmmenu It's very flexible.

snitko