|
Re: Catching a list of variables with a Controller: msg#00018lang.ruby.camping.general
This works for me: class Filter < R '/filter/([\w/]+)' def get tags @tags = tags.split('/') end end Then http://localhost:3301/filter/tag1/tag2/tag3 will make @tags into ['tag1', 'tag2', 'tag3']. I think this is what you want... Roland On Nov 14, 2006, at 3:42 PM, Boris Terzic wrote: > Hi All, > > I have been learning some ruby and some Camping at the same time by > implementing a little webapp to track expenses (one man's blog...) > that includes the ability to tag entries with 1 or more tags. > > I wanted to offer the possibility to narrow the view of expenses by > adding tags to a filter (this works) and I also wanted this filter > to be reflected in the URL. Like so: > > normal URL: http://localhost:3301/ > filtered URL: http://localhost:3301/filter/tag1/tag2/tag3 > > However, I can't get this to work since I require a variable number > of regexp groups (like say an array) and I could not find a routing > syntax that would allow this (something like class Filter < R '/ > filter/(\w/)*' ). > > I currently use a route which looks like: > > class Filter < R '/filter', '/filter/(.+)' > > And I represent the N tags as a string where tags are comma- > separated. It works but purty, it isn't. > > Suggestions? Or am I bonkers? > > Thanks. > > -- > Boris
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Re: RESTful mixin, mixin repo?, Jonas Pfenniger |
|---|---|
| Next by Date: | Re: Catching a list of variables with a Controller, Jonas Pfenniger |
| Previous by Thread: | Re: Catching a list of variables with a Controller, Manfred Stienstra |
| Next by Thread: | Re: Catching a list of variables with a Controller, Jonas Pfenniger |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |