Hello, I''m trying to set my routes.rb. I have Car that belongs to Color and Brand. I want to build a clear url searcher without visible variables. It''s working for me this: resources :Cars match ''color/:color'' => ''cars#index'' match ''brand/:brand'' => ''cars#index'' match ''brand/:brand/color/:color'' => ''cars#index'' But I think I could do the 3 "match" in only one line. Also, posibly there is other alternatives for do it. All advices are welcome. Thanks! -- 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.
For give a example, the url I hope to have is something like that: - example.com/brand/ford/color/red - example.com/brand/ford - example.com/color/red The idea is to have the same that: - example.com/cars?brand=ford&color=red But really, the user already knows that Ford is a brand and Red is a color. I would prefer to have a url like that: - example.com/ford/red In this case I would have to parse the string in the controller. I think would be okey this match: - match ''*search'' => ''cars#index'' Some advice? Thanks. -- 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.
Any help? -- 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.
danimashu wrote in post #997411:> I would prefer to have a url like that: > - example.com/ford/red >But then what happens with: - example.com/pink/cadillac ? I''d be careful of investing any particular logic behind your urls for dealing with arguments. Do all your users catagorize things the same way you do? Probably not. One person I work with definitely does not prioritize attributes in the order I do, and she is invaluable because of it. -- 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.
Thanks for the answer.> But then what happens with: > > - example.com/pink/cadillac ?In the controller would have to check that pink is a Color and cadillac is a Brand. Problem if some day there is a Brand with name of Color. I don''t know if it''s worth wasting time on it. The classic way sould be the correct then: - example.com/cars?color=pink&brand=cadillac If you have other ideas for do it you will be welcome. Bye Daniel -- 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.
On 10 May 2011 11:32, danimashu <daniel.madrid.reina-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for the answer. > >> But then what happens with: >> >> - example.com/pink/cadillac ? > > In the controller would have to check that pink is a Color and > cadillac is a Brand. Problem if some day there is a Brand with name of > Color. I don''t know if it''s worth wasting time on it. The classic way > sould be the correct then: > - example.com/cars?color=pink&brand=cadillacI would advise against a strategy that could ever be ambiguous, even if it looks unlikely at the moment. It would likely bite you at some point in the future, or even worse the developer who comes hereafter, can you imagine what he/she would say about you when he realised the problem and that he would have to do some major reworking? :) Colin -- 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.
> I would advise against a strategy that could ever be ambiguous, even > if it looks unlikely at the moment. It would likely bite you at some > point in the future, or even worse the developer who comes hereafter, > can you imagine what he/she would say about you when he realised the > problem and that he would have to do some major reworking? :) > > ColinThanks for the advice! For the moment I will use classic 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-/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.