Hello, I''m having trouble making my application restful. I want to show posts between 2 dates. For example posts between march 2007 and may 2007. I don''t know how to represent this timespan a single resource because it has 2 parts: from and to. The url I''m looking for is something like this /from/ 01-03-2007/to/01-05-2007/posts But that means that there are 3 resources here: "From" resource, "To" resource and "Posts". And nested routes would look something like this: map.resources :from do |from| from.resources :to do |to| to.resources :posts end end Is this solution ok, or there is some more elegant way of solving this? 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-/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 -~----------~----~----~----~------~----~------~--~---
How about start date and timespan, so start-dates are the basis of your url and timespan is a parameter. Just a thought :) On Jan 31, 8:59 pm, ajaxrussia <Aleksandr.Losse...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello, > > I''m having trouble making my application restful. I want to show posts > between 2 dates. > > For example posts between march 2007 and may 2007. I don''t know how to > represent this timespan a single resource because it has 2 parts: from > and to. The url I''m looking for is something like this /from/ > 01-03-2007/to/01-05-2007/posts > > But that means that there are 3 resources here: "From" resource, "To" > resource and "Posts". > > And nested routes would look something like this: > > map.resources :from do |from| > from.resources :to do |to| > to.resources :posts > end > end > > Is this solution ok, or there is some more elegant way of solving > this? > > 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-/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 -~----------~----~----~----~------~----~------~--~---
You mean like /from/01-03-2007/posts?to=01-05-2007 ? This is kind of ugly On Jan 31, 10:31 pm, apremdas <aprem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> How about start date and timespan, so start-dates are the basis of > your url and timespan is a parameter. > Just a thought :) > > On Jan 31, 8:59 pm, ajaxrussia <Aleksandr.Losse...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hello, > > > I''m having trouble making my application restful. I want to show posts > > between 2 dates. > > > For example posts between march 2007 and may 2007. I don''t know how to > > represent this timespan a single resource because it has 2 parts: from > > and to. The url I''m looking for is something like this /from/ > > 01-03-2007/to/01-05-2007/posts > > > But that means that there are 3 resources here: "From" resource, "To" > > resource and "Posts". > > > And nested routes would look something like this: > > > map.resources :from do |from| > > from.resources :to do |to| > > to.resources :posts > > end > > end > > > Is this solution ok, or there is some more elegant way of solving > > this? > > > 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-/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 -~----------~----~----~----~------~----~------~--~---
Well maybe, but you can get rid of the from and have posts/01-03-2007?to=01-05-2007 and if there is no ''to'' you''d just get the posts on the day. On Jan 31, 11:05 pm, ajaxrussia <Aleksandr.Losse...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You mean like /from/01-03-2007/posts?to=01-05-2007 ? > > This is kind of ugly > > On Jan 31, 10:31 pm, apremdas <aprem...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > How about start date and timespan, so start-dates are the basis of > > your url and timespan is a parameter. > > Just a thought :) > > > On Jan 31, 8:59 pm, ajaxrussia <Aleksandr.Losse...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hello, > > > > I''m having trouble making my application restful. I want to show posts > > > between 2 dates. > > > > For example posts between march 2007 and may 2007. I don''t know how to > > > represent this timespan a single resource because it has 2 parts: from > > > and to. The url I''m looking for is something like this /from/ > > > 01-03-2007/to/01-05-2007/posts > > > > But that means that there are 3 resources here: "From" resource, "To" > > > resource and "Posts". > > > > And nested routes would look something like this: > > > > map.resources :from do |from| > > > from.resources :to do |to| > > > to.resources :posts > > > end > > > end > > > > Is this solution ok, or there is some more elegant way of solving > > > this? > > > > 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-/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 Jan 31, 2008 3:59 PM, ajaxrussia <Aleksandr.Lossenko-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hello, > > I''m having trouble making my application restful. I want to show posts > between 2 dates. > > For example posts between march 2007 and may 2007. I don''t know how to > represent this timespan a single resource because it has 2 parts: from > and to. The url I''m looking for is something like this /from/ > 01-03-2007/to/01-05-2007/posts > > But that means that there are 3 resources here: "From" resource, "To" > resource and "Posts". > > And nested routes would look something like this: > > map.resources :from do |from| > from.resources :to do |to| > to.resources :posts > end > end > > Is this solution ok, or there is some more elegant way of solving > this?I think that the most natural way would be simply: /posts?from=01-03-2007&to=01-05-2007 This seems like a perfecly acceptable uri from a REST point of view, and your posts controller can simply look for params[:from], and params[:to] in the index action -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.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-/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 -~----------~----~----~----~------~----~------~--~---
I too am looking for a good way to expose a date parameter in a url using restful routing... I''d like to stay away from query string parameters (i.e. ?/&) in pursuit of cleaner urls without potential caching/search engine difficulties. For example, I like how Dopplr structures their urls quite a bit (probably using map.connect?): http://www.dopplr.com/traveller/adamjh/journal/2008/01/trips ... where 2008/01/trips are parameters used to scope journal results (2008/01 scopes the year/month, and trips filters the results to items of type ''trip'') Any ideas how I could achieve something similar with map.resources? :path_prefix can enable the type of parameter passing I need, but prepending them onto the url doesn''t yield the same logical structure I''m looking for (i.e. ability for a visitor to chop a parameter off the url and find herself a level higher in the site''s information architecture). Thanks, - Adam On Feb 1, 2:30 pm, "Rick DeNatale" <rick.denat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Jan 31, 2008 3:59 PM, ajaxrussia <Aleksandr.Losse...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hello, > > > I''m having trouble making my application restful. I want to show posts > > between 2 dates. > > > For example posts between march 2007 and may 2007. I don''t know how to > > represent this timespan a single resource because it has 2 parts:from > > and to. The url I''m looking for is something like this /from/ > > 01-03-2007/to/01-05-2007/posts > > > But that means that there are 3 resources here: "From" resource, "To" > > resource and "Posts". > > > And nested routes would look something like this: > > > map.resources :fromdo |from| > > from.resources :to do |to| > > to.resources :posts > > end > > end > > > Is this solution ok, or there is some more elegant way of solving > > this? > > I think that the most natural way would be simply: > > /posts?from=01-03-2007&to=01-05-2007 > > This seems like a perfecly acceptable urifroma REST point of view, > and your posts controller can simply look for params[:from], and > params[:to] in the index action > > -- > Rick DeNatale > > My blog on Rubyhttp://talklikeaduck.denhaven2.com/- Hide quoted text - > > - Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---