I want most, but not all routes created by map.resources

How do I do that?

I’m my case, I don’t want GET /resource/:id;edit and DELETE /
resource/:id

;edit is not needed for my app, and DELETE is not allowed.

Do I have create all the routes by hand? Or can I pass some kind of
except parameter to map.resources?

Ryan

You can pass restricted:
:restricted=>/new|create/

On Aug 8, 6:44 pm, Jeff [email protected] wrote:

Another approach is to go ahead an proactively implement controller
actions for those that shouldn’t be called, and return a 401 status or
something appropriate, by calling the “head” method to return a status
code.

Jeff

This is the approach I have taken. Thanks for the inputs.

On Aug 8, 2:18 pm, Josh S. [email protected]
wrote:

You can just ignore them. If you don’t implement the #edit and #destroy
actions in your controller, the routes won’t do anything. I’ve thought
about an :only or :except option for map.resources, but it seems like
overkill.

I agree.

Another approach is to go ahead an proactively implement controller
actions for those that shouldn’t be called, and return a 401 status or
something appropriate, by calling the “head” method to return a status
code.

Jeff

Ryan wrote:

How do I do that?

I’m my case, I don’t want GET /resource/:id;edit and DELETE /
resource/:id

;edit is not needed for my app, and DELETE is not allowed.

Do I have create all the routes by hand? Or can I pass some kind of
except parameter to map.resources?

Ryan

You can just ignore them. If you don’t implement the #edit and #destroy
actions in your controller, the routes won’t do anything. I’ve thought
about an :only or :except option for map.resources, but it seems like
overkill. If the presence of the superfluous routes really offends you,
you could remove them from the routes array with a bit of hackery, but
aside from a few more CPU cycles to not match the routes, they aren’t
hurting anyone by being there.


Josh S.
http://blog.hasmanythrough.com