How can I configure a REST route to accept multiple ids? for instance, in Highrise by 37signals tags have either routes like tags/47824 or tags/47824,43622,43628 I suppose it''s done with some regexp expertize, but I have none, and I wouldn''t know where to put it. A hand would be appreciated. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In the instance of those comma-separated multiple tags, params[:id] is "47824,43622,43628" and it''s just being split or handled in the method. I don''t think :id gets coerced to an integer because that could spoil implementations of routing which use to_param differently. [I could totally be off on that.] But I''m pretty sure that "47824,43622,43628" is just a string getting split on the commas something like Tag.find params[:id].split(",") I''d love to find out if I''m wrong and what the real implementation is. I''m kinda curious now. RSL On 10/3/07, midwaltz <stefeo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > How can I configure a REST route to accept multiple ids? > > for instance, in Highrise by 37signals tags have either routes like > tags/47824 > or > tags/47824,43622,43628 > > I suppose it''s done with some regexp expertize, but I have none, and I > wouldn''t know where to put it. A hand would be appreciated. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 Oct 4, 8:31 am, "Russell Norris" <r...-ftMzyaTR+bHNyFkoKTPOtdi2O/JbrIOy@public.gmane.org> wrote:> I''d love to find out if I''m wrong and what the real implementation is. > I''m kinda curious now.Russell, you are right. I just tried this using a Page model. You could also send up a list of the tag names instead of the id''s, making it a little more semantic (see Jonathan Linowes on http://www.vaporbase.com/postings/A_Micro-CMS_in_Rails). --~--~---------~--~----~------------~-------~--~----~ 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 how do I set a route for that? Right now I get this error: no route found to match "/tags/19,16" with {:method=>:get} I''m on rails 1.2.4. Are you on 2.0, or am I missing something else? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Add this to your environment.rb ActionController::Routing::SEPARATORS = %w(/ ; . ?) On Oct 5, 7:44 am, midwaltz <ste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> but how do I set a route for that? Right now I get this error: > > no route found to match "/tags/19,16" with {:method=>:get} > > I''m on rails 1.2.4. Are you on 2.0, or am I missing something else?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
OK, that works, thanks Pablo. So if I by adding this line I''m actually removing '','' from the SEPARATORS array... You''ve introduced me to SEPARATORS, and made me understand I could use any characters except the ones in that array. So instead of adding that line and using '','' II decided to simply use ''+'', à la del.icio.us. There''s no drawbacks in using ''+'' is there? For example: tags/645+456+456 On Oct 7, 10:02 pm, Pablo Castellazzi <pablo.castella...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Add this to your environment.rb > ActionController::Routing::SEPARATORS = %w(/ ; . ?) > > On Oct 5, 7:44 am, midwaltz <ste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > but how do I set a route for that? Right now I get this error: > > > no route found to match "/tags/19,16" with {:method=>:get} > > > I''m on rails 1.2.4. Are you on 2.0, or am I missing something else?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
It works, but "+" is a space URL encoded (RFC1738). That''s mean in your controller you should split by spaces instead of ''+''. On Oct 8, 9:36 am, midwaltz <ste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> OK, that works, thanks Pablo. > > So if I by adding this line I''m actually removing '','' from the > SEPARATORS array... You''ve introduced me to SEPARATORS, and made me > understand I could use any characters except the ones in that array. > So instead of adding that line and using '','' II decided to simply use > ''+'', à la del.icio.us. There''s no drawbacks in using ''+'' is there? For > example: > > tags/645+456+456 > > On Oct 7, 10:02 pm, Pablo Castellazzi <pablo.castella...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > Add this to your environment.rb > > ActionController::Routing::SEPARATORS = %w(/ ; . ?) > > > On Oct 5, 7:44 am, midwaltz <ste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > but how do I set a route for that? Right now I get this error: > > > > no route found to match "/tags/19,16" with {:method=>:get} > > > > I''m on rails 1.2.4. Are you on 2.0, or am I missing something else?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---