Hi, I''ve implemented a restful app where I can post comments. If I use http://127.0.0.1:3000/programs/1/comments I get all the comments for program 1 In the main page of the programs I can see all the programs and the LAST comment for each program. That I use a helper function that just takes the last comment. Now. I want to do the same thing but the response is sent to a client in xml. So I can http://127.0.0.1:3000/programs/1/comments.xml and again I get xml for all the comments. What is the best way to request the last comment? Using the same request but adding a parameter? Creating a custom action? 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 -~----------~----~----~----~------~----~------~--~---
On Mar 19, 8:13 am, comopasta Gr <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> What is the best way to request the last comment? Using the same request > but adding a parameter? Creating a custom action?I would add a parameter instead of a custom action: /programs/1/comments?filter=last In your controller, you can look at params[:filter] to find out what kind of filter the client wants - you could support values like last, first, or a number if they want to simply limit the result set. Jeff softiesonrails.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 -~----------~----~----~----~------~----~------~--~---
Jeff Cohen wrote:> I would add a parameter instead of a custom action: > > /programs/1/comments?filter=lastYeah I''ll do it like that. Somehow I get the feeling that adding parameters to a clean restful request breaks the rest rules. But I guess that is a normal way of doing it. 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 -~----------~----~----~----~------~----~------~--~---