I am having some trouble in trying to figure out how to add a date and time to my URL and leave out the :id. I have map.resources :events do |events| events.resources :showtimes end the url I want to be shown is /events/1/showtimes/2007-2-14/18/00 but what I am getting is /events/1/showtimes/1 I know I can do a :path_prefix and have the date and time put in before showtimes, but that''s not what I want. Any help would be great. ALSO, a buddy of mine thinks that REST conflicts with Object thinking, I just wanted to get everyone else''s opinion on that. 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jeremy Woertink wrote:> I am having some trouble in trying to figure out how to add a date and > time to my URL and leave out the :id. > > I have > > map.resources :events do |events| > events.resources :showtimes > end > > the url I want to be shown is /events/1/showtimes/2007-2-14/18/00 > > but what I am getting is /events/1/showtimes/1You may not be able to use restful routes with this. Simply because that route is not restful. REST says every resource has a single ID, yet that route has 3 bits of data to identify a showtime: date, hour and minute. you might be able to do a route like: /events/1/showtimes/2007-2-14-18-00/ by doing something like class Showtime < ActiveRecord::Base def to_param time.strftime(''someformattingstringhere'') end end But you will have to fetch all your stuff via Showtime.find_by_time(params[:id]) Since you id is now a time stamp, instead of a primary key.> ALSO, a buddy of mine thinks that REST conflicts with Object thinking, I > just wanted to get everyone else''s opinion on that.Object thinking? Is that a cult? If anything, it makes the web more object oriented by identifying a specific url with a specific object or resource. HTTP verbs are like the methods on that object. Makes more OO sense to me than a bunch of controllers that you can''t really tell what data they manipulate without looking at the source code. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne wrote:> Object thinking? Is that a cult? > > If anything, it makes the web more object oriented by identifying a > specific url with a specific object or resource. HTTP verbs are like > the methods on that object. Makes more OO sense to me than a bunch of > controllers that you can''t really tell what data they manipulate without > looking at the source code.I''m that buddy. No, object thinking is not a cult. I prefer that phrase because it is less bogged down by the abuse of the term object-oriented. "OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things." - Alan Kay, father of OOP I think REST violates OT in a very subtle fashion. Objects have responsibilities _as defined by the problem-space_. Decomposition of the domain, its problems and its objects helps to create objects that are light and well-defined. There are no limits on what an object can do save what the problem domain defines. REST seeks to minimize the number of responsibilities an object can assume, while increasing the number of objects in the problem domain, sometimes absurdly so. REST places no limits on the kinds of objects that can be created, and too many choices can lead to crappy choices being made.> Makes more OO sense to me than a bunch of > controllers that you can''t really tell what data > they manipulate without looking at the source code.This can also be true of a REST-oriented web site. Just because you''re using REST techniques doesn''t mean your implementation makes sense, or is really REST-like. Likewise with what so many people consider to be object-oriented code. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 14, 2007, at 5:06 PM, Alex Wayne wrote:>> the url I want to be shown is /events/1/showtimes/2007-2-14/18/00 >> >> but what I am getting is /events/1/showtimes/1 > > You may not be able to use restful routes with this. Simply because > that route is not restful. REST says every resource has a single ID, > yet that route has 3 bits of data to identify a showtime: date, > hour and > minute.I thought REST just says a resource has a single *URL*. Its Rails that''s imposing the single-ID requirement. To the original poster, you can definitely do RESTful URL''s, you just have to do more work, and can''t use the handy map.resources, since that''s imposing the single-ID req. -pete -- (peter.royal|osi)@pobox.com - http://fotap.org/~osi