I''m reading the book ''RESTful web services'' and in the discussion on exposing algorithmic resources it says the following: " Most web applications don’t store much state in path variables: they use query variables instead. You may have seen URIs like this: • http://www.example.com/articles?start=20061201&end=20071201 Those URIs would look better without the query variables: • http://www.example.com/articles/20061201-20071201 " What is the Rails way for exposing algorithmic resources? Is it via the first URL in the example or the second? If it is the second, please can you give me some guidance on how to achieve this. Thanks -- 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-/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 -~----------~----~----~----~------~----~------~--~---
start, finish = "20061201-20071201".split(''-'') "end" is reserved keyword Tim Conner wrote:> I''m reading the book ''RESTful web services'' and in the discussion on > exposing algorithmic resources it says the following: > > " > Most web applications don’t store much state in path variables: they use > query variables instead. You may have seen URIs like this: > • http://www.example.com/articles?start=20061201&end=20071201 > > Those URIs would look better without the query variables: > • http://www.example.com/articles/20061201-20071201 > " > > What is the Rails way for exposing algorithmic resources? Is it via the > first URL in the example or the second? If it is the second, please can > you give me some guidance on how to achieve this. > Thanks >-- irfani http://irfani.web.id Y! irfani_s --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Those URIs would look better without the query variables: > • http://www.example.com/articles/20061201-20071201 > " > > What is the Rails way for exposing algorithmic resources? Is it via the > first URL in the example or the second? If it is the second, please can > you give me some guidance on how to achieve this. > ThanksRails conventions says that /articles/20061201-20071201 finds the article with the id ''20061201-20071201''. Anything other than that would be unconventional. There are of course conventions to breaking the conventions, though ; ) Personally, I''d do something like map.article_range ''/articles/:range'', :action => ''range'', :requirements => {:range => /(d+)\-(d+)/}. In the ''range'' action, I''d do what YangBaikHati suggests above. start, finish = params[:range].split(''-''). -- 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-/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 -~----------~----~----~----~------~----~------~--~---