Here is the situation we are facing: Imagine we have a resource Parent that has Child resources. To edit a Child, you can access it by its ID. But to view Children, you need to know the parent ID as well. This leads to the following:
resources :parents do # for parents/* resources :children # for parents/:parent_id/children/index end resources :children # for children/id/*, but not /children/index Now, everything works just fine, but you end up with lots of extra routes that never get used. This makes rake audit:routes less useful than it could be, and just seems a little messy. This is why I am looking forward to the Resource enhancements that Yehuda keeps mentioning. It would be great to have a more concise way of specifying the CRUD routes. ..tony.. On Wed, Dec 17, 2008 at 12:07 AM, Asche <[email protected]> wrote: > > I don't think there is a need to manually remove routes - if you don't > want to offer a particular action just don't write methods that you > don't want for the particular controller. > If you want to find by "slug" rather than "id" you could do something > like, "resources :article, :identify => :slug", and resouce(@article) > will generate "/articles/my-slug" > > If Merb is similar to Rails in this regard, the method > "resources :resource" is just an easy way of specifying restful > routes, and it doesn't do anything special that you can't do manually. > > match("articles/:slug").to(:controller => 'articles', :action => > 'show').name(:article) > > Hope that helps. > > > On Dec 16, 9:36 pm, cult hero <[email protected]> wrote: > > Let's say I go ahead and use "resources <resource>" in my router.rb to > > create some generic routes for something but I only want a subset of > > those routes. (For instance, let's say I don't want to "show" by id, > > but rather, by a slug field.) > > > > Should I create my routes from scratch or is there a good way of > > removing a couple of the routes generated by the resources method? I > > was thinking you could create a controller that just automatically > > raises a NotFound exception, but that seems like a bit of a kludge. > > > > Part of this question comes from me trying to understand CRUD in merb > > but the examples on the wiki all seem to be based around resources > > which is adding an extra layer of stuff for me to grok. > > > > (As a side note, I'm coming from a limited Django background and NOT a > > Rails background, so a lot of these conventions are quite a bit more > > foreign to me than they might be to others.) > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "merb" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/merb?hl=en -~----------~----~----~----~------~----~------~--~---
