Hey guys, I''m quite new in RoR, so please excuse me when I may ask weird questions. I am working on a database frontend. The layout looks mostly like a has_many bs b has_many cs c has_many ds and so on. Now I want to do some selection. Maybe I want to see all ds belonging to a specific b. I would like to do it like: http://my.host/bs/1/ds When I click around there (add new ds, show a d or whatever), I would like to keep that b, so I always get like /bs/1/d/new and end up in /bs/1/ds again. Now comes the tricky part. I also want to have the same behavior for /as/1/ds and /cs/1/ds. When possible even for /as/1/cs/3/ds. I could do this by creating every route manually and touching every link, at least I know how to create the link for show (just [@b, d]), I would probably figure out how to create the other ones. But as I know RoR, there should be an easier way to do this. Surprisingly, I did not yet find one, so maybe you can give me hints how this could be done. Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jo Bu wrote in post #969496:> Hey guys, > I''m quite new in RoR, so please excuse me when I may ask weird > questions. > > I am working on a database frontend. The layout looks mostly like > a has_many bs > b has_many cs > c has_many ds > and so on. Now I want to do some selection. Maybe I want to see all ds > belonging to a specific b. I would like to do it like: > http://my.host/bs/1/dsYou want nested resources. Read the routing docs. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Marnen Laibow-Koser wrote in post #969567:> You want nested resources. Read the routing docs.Well yes, I could do that, but it would become very confusing. But I would more like a solution like (in pseudocode) if (URL matches "/a/:a_id/!(create|new|show|edit).*") set @a=A.find_by_id(:a_id) Is that possible? And then I would have to rewrite link_to to prefix with the given values, right? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Have a look at https://github.com/jamesgolick/resource_controller It won''t solve all your problems, but some. On Dec 21, 8:32 am, Jo Bu <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Marnen Laibow-Koser wrote in post #969567: > > > You want nested resources. Read the routing docs. > > Well yes, I could do that, but it would become very confusing. But I > would more like a solution like (in pseudocode) > if (URL matches "/a/:a_id/!(create|new|show|edit).*") > set @a=A.find_by_id(:a_id) > Is that possible? > And then I would have to rewrite link_to to prefix with the given > values, right? > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Simon Baumgartner wrote in post #969774:> Have a look at https://github.com/jamesgolick/resource_controllerThat looks very helpful, thank you! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.