I have a number of resources that I want to access in various scopes. The index action would change slightly depending on its scope, but the rest of the actions would be identical aside from needing to preserve the url scope in links and redirects. For example: map.resources :categories do |categories| categories.resources :products do |products| products.resources :components end end map.resources :products do |products| products.resources :components end map.resources :components This enables the following routes all to work: /categories/1/products/1/components/1 /products/1/components/1 /components/1 However, if I understand correctly, I have to specify which route in the named routes: category_product_components_path product_components_path components_path I''d like to be able to use components_path and have it be smart enough based on the options and params to preserve as much scoped routing as possible. For example: Calling components_path in /categories/1/products/1 -> /categories/1/products/1/components Calling components_path in /products/1 -> /products/1/components Calling components_path somewhere else -> /components Is there any way to do this? -- Jack Christensen jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
category_product_components_path is the only way afaik, without hacking up your own version of it. Why would you need to have 3-level deep nested routes anyway? "/categories/1/products/1/components/1/" Really all you''re looking at here is the component, who cares what category and product it''s from, you can do that query in the controller. On Jan 11, 2008 9:17 AM, Jack Christensen <jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org> wrote:> > I have a number of resources that I want to access in various scopes. > The index action would change slightly depending on its scope, but the > rest of the actions would be identical aside from needing to preserve > the url scope in links and redirects. > > For example: > > map.resources :categories do |categories| > categories.resources :products do |products| > products.resources :components > end > end > > map.resources :products do |products| > products.resources :components > end > > map.resources :components > > > This enables the following routes all to work: > > /categories/1/products/1/components/1 > /products/1/components/1 > /components/1 > > However, if I understand correctly, I have to specify which route in the > named routes: > > category_product_components_path > product_components_path > components_path > > I''d like to be able to use components_path and have it be smart enough > based on the options and params to preserve as much scoped routing as > possible. For example: > > Calling components_path in /categories/1/products/1 -> > /categories/1/products/1/components > Calling components_path in /products/1 -> /products/1/components > Calling components_path somewhere else -> /components > > Is there any way to do this? > > -- > Jack Christensen > jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> <title></title> </head> <body bgcolor="#ffffff" text="#000000"> Ryan Bigg wrote: <blockquote cite="mid:cfbf2b0801101455g2e9e7ef5qd94203c104e827e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org" type="cite">category_product_components_path is the only way afaik, without hacking up your own version of it.<br> <br> Why would you need to have 3-level deep nested routes anyway? "/categories/1/products/1/components/1/" Really all you''re looking at here is the component, who cares what category and product it''s from, you can do that query in the controller. <br> </blockquote> For the components index page I need to know if I should display all components or only those that belong to the given product. For the actions like show, edit and update I need to preserve that state so when I go back to the index I go back to the right index page. The user will start on an index page at some level of scoping, he then goes to show a component. At this point I have the referer so I don''t have a problem going back yet. Then if he goes from show to edit and update that component. At this point if I''m only at "/components/1" I have no way of knowing what index page I should go back to.<br> <br> In my production system I have many resources that have many relations (one model has ~30 associations). So there are are many places where I need an index of all records that belong to another, to be able to do multiple actions to an individual record, and finally go back to the original index page.<br> <br> I have used the session to to store where I should go back to, but that has its own nasty set of problems. It seems that this state should be kept in the URL.<br> <blockquote cite="mid:cfbf2b0801101455g2e9e7ef5qd94203c104e827e5-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org" type="cite"> <div class="gmail_quote">On Jan 11, 2008 9:17 AM, Jack Christensen <<a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a>> wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br> I have a number of resources that I want to access in various scopes.<br> The index action would change slightly depending on its scope, but the<br> rest of the actions would be identical aside from needing to preserve<br> the url scope in links and redirects.<br> <br> For example:<br> <br> map.resources :categories do |categories|<br> categories.resources :products do |products|<br> products.resources :components<br> end<br> end<br> <br> map.resources :products do |products|<br> products.resources :components<br> end<br> <br> map.resources :components<br> <br> <br> This enables the following routes all to work:<br> <br> /categories/1/products/1/components/1<br> /products/1/components/1 <br> /components/1<br> <br> However, if I understand correctly, I have to specify which route in the<br> named routes:<br> <br> category_product_components_path<br> product_components_path<br> components_path<br> <br> I''d like to be able to use components_path and have it be smart enough <br> based on the options and params to preserve as much scoped routing as<br> possible. For example:<br> <br> Calling components_path in /categories/1/products/1 -><br> /categories/1/products/1/components<br> Calling components_path in /products/1 -> /products/1/components <br> Calling components_path somewhere else -> /components<br> <br> Is there any way to do this?<br> <br> --<br> Jack Christensen<br> <a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a><br> <br> <br> <a class="moz-txt-link-freetext" href="http://www.frozenplague.net">http://www.frozenplague.net</a><br> Feel free to add me to MSN and/or GTalk as this email.<br> <br> </blockquote> </div> </blockquote> <br> <br> <pre class="moz-signature" cols="72">-- Jack Christensen <a class="moz-txt-link-abbreviated" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a></pre> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. <br> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>
Ok, well /products/1/components/1 will let you go back as far as you need to go back, right? On Jan 11, 2008 1:00 PM, Jack Christensen <jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org> wrote:> Ryan Bigg wrote: > > category_product_components_path is the only way afaik, without hacking up > your own version of it. > > Why would you need to have 3-level deep nested routes anyway? > "/categories/1/products/1/components/1/" Really all you''re looking at here > is the component, who cares what category and product it''s from, you can do > that query in the controller. > > For the components index page I need to know if I should display all > components or only those that belong to the given product. For the actions > like show, edit and update I need to preserve that state so when I go back > to the index I go back to the right index page. The user will start on an > index page at some level of scoping, he then goes to show a component. At > this point I have the referer so I don''t have a problem going back yet. Then > if he goes from show to edit and update that component. At this point if I''m > only at "/components/1" I have no way of knowing what index page I should go > back to. > > In my production system I have many resources that have many relations > (one model has ~30 associations). So there are are many places where I need > an index of all records that belong to another, to be able to do multiple > actions to an individual record, and finally go back to the original index > page. > > I have used the session to to store where I should go back to, but that > has its own nasty set of problems. It seems that this state should be kept > in the URL. > > On Jan 11, 2008 9:17 AM, Jack Christensen <jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org> wrote: > > > > > I have a number of resources that I want to access in various scopes. > > The index action would change slightly depending on its scope, but the > > rest of the actions would be identical aside from needing to preserve > > the url scope in links and redirects. > > > > For example: > > > > map.resources :categories do |categories| > > categories.resources :products do |products| > > products.resources :components > > end > > end > > > > map.resources :products do |products| > > products.resources :components > > end > > > > map.resources :components > > > > > > This enables the following routes all to work: > > > > /categories/1/products/1/components/1 > > /products/1/components/1 > > /components/1 > > > > However, if I understand correctly, I have to specify which route in the > > named routes: > > > > category_product_components_path > > product_components_path > > components_path > > > > I''d like to be able to use components_path and have it be smart enough > > based on the options and params to preserve as much scoped routing as > > possible. For example: > > > > Calling components_path in /categories/1/products/1 -> > > /categories/1/products/1/components > > Calling components_path in /products/1 -> /products/1/components > > Calling components_path somewhere else -> /components > > > > Is there any way to do this? > > > > -- > > Jack Christensen > > jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org > > > > > > http://www.frozenplague.net > > Feel free to add me to MSN and/or GTalk as this email. > > > > > > -- > Jack Christensenjackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org > > > > >-- Ryan Bigg http://www.frozenplague.net Feel free to add me to MSN and/or GTalk as this email. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type"> </head> <body bgcolor="#ffffff" text="#000000"> Ryan Bigg wrote: <blockquote cite="mid:cfbf2b0801101902l781a092ar2ebfd7c795a0d6b6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org" type="cite">Ok, well /products/1/components/1 will let you go back as far as you need to go back, right?<br> </blockquote> Correct, assuming I came through /categories/products/1. The problem is I may have just come through /products/1. I basically just need to keep whatever the prefix is before the /components. I have hacked together some custom url helpers in which I list all the possible entrance paths and the params that trigger that path. It more or less works, but in theory all the information I''m duplicating in those helpers exists in the routes somewhere. Maybe I should look into reflecting on routes.<br> <blockquote cite="mid:cfbf2b0801101902l781a092ar2ebfd7c795a0d6b6-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org" type="cite"><br> <div class="gmail_quote">On Jan 11, 2008 1:00 PM, Jack Christensen <<a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org </a>> wrote:<br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div bgcolor="#ffffff" text="#000000"> <div class="Ih2E3d">Ryan Bigg wrote: <blockquote type="cite">category_product_components_path is the only way afaik, without hacking up your own version of it.<br> <br> Why would you need to have 3-level deep nested routes anyway? "/categories/1/products/1/components/1/" Really all you''re looking at here is the component, who cares what category and product it''s from, you can do that query in the controller. <br> </blockquote> </div> For the components index page I need to know if I should display all components or only those that belong to the given product. For the actions like show, edit and update I need to preserve that state so when I go back to the index I go back to the right index page. The user will start on an index page at some level of scoping, he then goes to show a component. At this point I have the referer so I don''t have a problem going back yet. Then if he goes from show to edit and update that component. At this point if I''m only at "/components/1" I have no way of knowing what index page I should go back to.<br> <br> In my production system I have many resources that have many relations (one model has ~30 associations). So there are are many places where I need an index of all records that belong to another, to be able to do multiple actions to an individual record, and finally go back to the original index page.<br> <br> I have used the session to to store where I should go back to, but that has its own nasty set of problems. It seems that this state should be kept in the URL.<br> <blockquote type="cite"> <div class="gmail_quote"> <div> <div class="Wj3C7c">On Jan 11, 2008 9:17 AM, Jack Christensen <<a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org" target="_blank">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a>> wrote:<br> </div> </div> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div> <div class="Wj3C7c"><br> I have a number of resources that I want to access in various scopes.<br> The index action would change slightly depending on its scope, but the<br> rest of the actions would be identical aside from needing to preserve<br> the url scope in links and redirects.<br> <br> For example:<br> <br> map.resources :categories do |categories|<br> categories.resources :products do |products|<br> products.resources :components<br> end<br> end<br> <br> map.resources :products do |products|<br> products.resources :components<br> end<br> <br> map.resources :components<br> <br> <br> This enables the following routes all to work:<br> <br> /categories/1/products/1/components/1<br> /products/1/components/1 <br> /components/1<br> <br> However, if I understand correctly, I have to specify which route in the<br> named routes:<br> <br> category_product_components_path<br> product_components_path<br> components_path<br> <br> I''d like to be able to use components_path and have it be smart enough <br> based on the options and params to preserve as much scoped routing as<br> possible. For example:<br> <br> Calling components_path in /categories/1/products/1 -><br> /categories/1/products/1/components<br> Calling components_path in /products/1 -> /products/1/components <br> Calling components_path somewhere else -> /components<br> <br> Is there any way to do this?<br> <br> --<br> Jack Christensen<br> <a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org" target="_blank">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a><br> <br> <br> </div> </div> <div class="Ih2E3d"><a moz-do-not-send="true" href="http://www.frozenplague.net" target="_blank">http://www.frozenplague.net</a><br> Feel free to add me to MSN and/or GTalk as this email.<br> <br> </div> </blockquote> </div> </blockquote> <br> <br> <pre cols="72">-- Jack Christensen <a moz-do-not-send="true" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org" target="_blank">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a></pre> <div class="Ih2E3d"><br> <br> </div> </div> <br> </blockquote> </div> <br> <br clear="all"> <br> -- <br> Ryan Bigg<br> <a moz-do-not-send="true" href="http://www.frozenplague.net">http://www.frozenplague.net</a><br> Feel free to add me to MSN and/or GTalk as this email.<br> <br> </blockquote> <br> <br> <pre class="moz-signature" cols="72">-- Jack Christensen <a class="moz-txt-link-abbreviated" href="mailto:jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org">jackc-/SOt/BrQZzMOf2zXYvRtkodd74u8MsAO@public.gmane.org</a></pre> <br> --~--~---------~--~----~------------~-------~--~----~<br> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. <br> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <br> For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en <br> -~----------~----~----~----~------~----~------~--~---<br> </body> </html> <br>