Hello people :) I''m bad in English, so i''ll be short. It newbie question, I think) In my application I has users, which :has_many => posts. In routes.rb I can with ease create routes for posts like /:user_id/posts/..., but I wish to have something like /posts/:user_id/... instead. And use map.resources syntax to be one-liner, of course :) Can I possibly do that? Thank in advance! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi there, I have article display set-up on my side as follows: map.article ''article/show/:permalink'', :controller => ''article'', :action => ''show'' So you might be looking for something like this: map.posts ''/posts/:user_id'', :controller => ''posts'', :action =< ''show'' HTH, Schalk Skaurus wrote:> Hello people :) > > I''m bad in English, so i''ll be short. It newbie question, I think) > > In my application I has users, which :has_many => posts. In routes.rb > I can with ease create routes for posts like /:user_id/posts/..., but > I wish to have something like /posts/:user_id/... instead. And use > map.resources syntax to be one-liner, of course :) > > Can I possibly do that? > > Thank in advance! > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 6 апр, 16:18, Schalk Neethling <volume4.sch...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi there, > > I have article display set-up on my side as follows: > map.article ''article/show/:permalink'', :controller => ''article'', :action > => ''show'' > > So you might be looking for something like this: > map.posts ''/posts/:user_id'', :controller => ''posts'', :action =< ''show'' > > HTH, > Schalk >So for scaffold-generated resourse I have to create seven routes :( --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
And url-generation for this routes a pretty ugly in views: instead of show_post_path I write now show_post_url(:user_id => post.author_id, :post_id => post.id) Maybe some another way? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
form_for(@post) breaks too. On 7 апр, 03:03, Skaurus <skau...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And url-generation for this routes a pretty ugly in views: instead of > show_post_path I write now show_post_url(:user_id => > post.author_id, :post_id => post.id) > > Maybe some another way?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---