Hello, I was wondering how do I use the respond_to xml ? class PeopleController < ApplicationController def index @peope = People.find(:all) respond_to do | request | request.html { } request.xml { render :xml => @people..to_xml(:except => [:id]) } end end end I tried with this and I always get execution timeout? result = Net::HTTP.get(URI(''http://localhost:3000/people'')) @people = REXML::Document.new(result) How can I get the my index to response with XML? Thanks for any help :) -- 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 Nov 3, 2007, at 1:48 PM, Jamal Soueidan wrote:> class PeopleController < ApplicationController > def index > @peope = People.find(:all) > respond_to do | request | > request.html { } > request.xml { render :xml => @people..to_xml(:except => > [:id])The couple of dots is a typo.> result = Net::HTTP.get(URI(''http://localhost:3000/people'')) > @people = REXML::Document.new(result) > > How can I get the my index to response with XML?If you have declared map.resources :people then you can specify the desired "xml" format this way: http://localhost:3000/people.xml -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 3 Nov 2007, at 12:48, Jamal Soueidan wrote:> > I tried with this and I always get execution timeout? > > result = Net::HTTP.get(URI(''http://localhost:3000/people'')) > @people = REXML::Document.new(result) >Are you doing this from the same rails app? in dev mode you typically only have 1 mongrel, if 1 is busy executing the above code that leaves no one to handle the request you;re making. On top of that you need to tell it you want xml. You can either do this by setting the Accept header or by saying you want people.xml (assuming you''ve got the standard routes setup) Fred