Hi, In my app, I''ve got a Page model and in my routes.rb have the line: map.resources :pages This gives me all of the nice urls for all of the CRUD actions. However, for showing pages, I didn''t like the urls pages/5 wasn''t very descriptive. I preferered ''nice'' urls such as blog/about-me. I could use the to_params method to specify using permalinks instead, but you still had to put pages/ in front of the permalink and I couldn''t find a way to avoid having the model name at the start of urls. I''ve come up with a route that solves this problem and people can access the pages using this ''nice'' notation and I can generate it using the helper nice_page_path(@page). But since I don''t actually use the page_path(@page) helper it would be nice if I could use this to generate my ''nice'' paths instead of having a custom helper called nice_page_path. Is there an option you can pass to map.resources to say that you don''t want one of the routes? Or is there a way of overriding this helper so I can use it for my paths instead? thanks, DAZ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> But since I don''t actually use the page_path(@page) helper it would be > nice if I could use this to generate my ''nice'' paths instead of having > a custom helper called nice_page_path. Is there an option you can pass > to map.resources to say that you don''t want one of the routes? Or is > there a way of overriding this helper so I can use it for my paths > instead? >You might think it would be nice, but it sort of defeats the one of the purposes of REST, which is for all sites to follow a standard for the basic 7 actions. If you have a route that works the way you want it to, and a helper that produces the url''s the way you want it to, why do you feel you need to wreck/disable the standard RESTful actions and the rest of the world''s RESTful access to your site content? As long as they can get your content with "pretty" url''s when they want to, is there really a problem with people/programs still being able to reach your content via "/pages/5"? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That''s a good point Cayce, thanks. I was thinking of keeping both ways of accessing the pages and now you''ve helped to convince me that I should keep that convention in place. I still think that using permalinks such as /blog/about-me is much more descriptive than pages/5 and also think that in this one case a ''pages'' model is one where you wouldn''t want the url to be preceded by the word ''pages''. I can certainly understand why you would in other cases - ''products'', ''episodes'' etc, but it is usually taken as a given that what you are looking at is a page (although maybe not when we are supposed to be assuming that everything is a resource....) Thanks again, DAZ On Jun 3, 1:18 am, Cayce Balara <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > But since I don''t actually use the page_path(@page) helper it would be > > nice if I could use this to generate my ''nice'' paths instead of having > > a custom helper called nice_page_path. Is there an option you can pass > > to map.resources to say that you don''t want one of the routes? Or is > > there a way of overriding this helper so I can use it for my paths > > instead? > > You might think it would be nice, but it sort of defeats the one of the > purposes of REST, which is for all sites to follow a standard for the > basic 7 actions. If you have a route that works the way you want it to, > and a helper that produces the url''s the way you want it to, why do you > feel you need to wreck/disable the standard RESTful actions and the rest > of the world''s RESTful access to your site content? As long as they can > get your content with "pretty" url''s when they want to, is there really > a problem with people/programs still being able to reach your content > via "/pages/5"? > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Tuesday 03 June 2008 02:18:22 Cayce Balara wrote:> You might think it would be nice, but it sort of defeats the one of > the purposes of REST, which is for all sites to follow a standard for > the basic 7 actions.Uniforum naming of actions and objects is a popular goal of many people, but not a purpose of REST. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIRoelpGJX8XSgas0RAhjYAKCJdIcX4ot3dMWT7kx3urkha0yzFwCglXdE G/VHU/Emzry9GjKNQ8rLI3Y=ETPj -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks for clearing that up Sheldon. Like I said already, having names like /blog/about-me makes more sense in this case because it also give information about the parent page (blog) of the page being found (about-me), so adds some scope to the url that you wouldn''t get from / pages/5. I''m in two minds here - should I allow both urls as some people might expect the ''convention'' of /pages/5 or should I try to keep things like the id of the page private to the application? Also, with regard to my original question, is it possible to EXCLUDE some of the helpers from map.resources? Should it be possible? If not and this isn''t the purpose of REST then why force this style of url? cheers, DAZ On Jun 4, 1:16 pm, Sheldon Hearn <sheld...-UjuPna88SMAqcZcGjlUOXw@public.gmane.org> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On Tuesday 03 June 2008 02:18:22 Cayce Balara wrote: > > > You might think it would be nice, but it sort of defeats the one of > > the purposes of REST, which is for all sites to follow a standard for > > the basic 7 actions. > > Uniforum naming of actions and objects is a popular goal of many people, > but not a purpose of REST. > > Ciao, > Sheldon. > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.6 (GNU/Linux) > > iD8DBQFIRoelpGJX8XSgas0RAhjYAKCJdIcX4ot3dMWT7kx3urkha0yzFwCglXdE > G/VHU/Emzry9GjKNQ8rLI3Y> =ETPj > -----END PGP SIGNATURE-------~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 04 June 2008 14:26:13 DAZ wrote:> I''m in two minds here - should I allow both urls as some people might > expect the ''convention'' of /pages/5 or should I try to keep things > like the id of the page private to the application?That''s hard for me to answer, because I can''t imagine a situation in which an outside consumer of your web service could possibly know that it''s interested in doing something with page 5, without already knowing enough about page 5 to know that its slug is about-me. :-) That said, the existence of the unpublished routes isn''t hurting you.> Also, with regard to my original question, is it possible to EXCLUDE > some of the helpers from map.resources?No. The whole point of ActionController::Resources#resources is to map routes to a "RESTful resource". That has specific meaning, and includes things like: if you GET /page/5, I''ll route you to the PageController''s show action, passing it an id parameter of 5. Perhaps the confusion here comes from people collapsing the term REST with the term RESTful resource. If you don''t want to implement RESTful resources, don''t use ActionController::Resources#resources to map routes. But again, they''re not hurting you. Personally, I don''t mind pretty URLs when someone else implements them in software I use (e.g. Mephisto Blog), but I never implement them myself. I think they''re pointless, particularly in the kinds of applications I write. Ciao, Sheldon. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIRq9wpGJX8XSgas0RAj1FAJ9+A3VoEndvlw+aKuJ6FB62Q5DGngCfeJXw /XHWHwIB36PkLgk/l/NejZQ=YH+Y -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---