Argument Error when trying to render xml

I have an application which uses gcal4ruby and retrieves events from a Calendar object. The events are received fine and I can look at them in the console however, when I try to render them in xml by using the following line

render :xml => e

I get the ArgumentError, 'wrong number of arguments (1 for 0)'. Just to see if the data is there, I also did 'render :text => e.to_xml', the object is displayed (the xml labels are swallowed up by the browser but I can see the content).

I've search all over for what possible reason render :xml would fail with this error but I'm having no luck.

Any ideas are greatly appreciated.

Here's the controller code:     s.authenticate('mylogin','mypassword')     @cal=Calendar.find(s,{:title=>"Public"}).first     @events =     e=@events.first     respond_to do |format|       format.html { render :xml => e }     end

Here's the end of the stack trace:

ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ renderers.rb:87:in `to_xml' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ renderers.rb:87:in `_render_option_xml' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ renderers.rb:40:in `_handle_render_options' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ renderers.rb:47:in `render_to_body' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ compatibility.rb:55:in `render_to_body' ruby/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb: 101:in `render_to_string' ruby/1.8/gems/actionpack-3.0.3/lib/abstract_controller/rendering.rb: 92:in `render' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ rendering.rb:17:in `render' ruby/1.8/gems/actionpack-3.0.3/lib/action_controller/metal/ instrumentation.rb:40:in `render' ...

Couple of things here:

  1. respond_to is Rails 2 way of doing things, it’s more convenient to use respond_with in Rails 3

  2. If you want to send back xml, then you should ideally be sending in a xml request instead on html request

If you want to stick with respond_to call and always render xml from this method… then you can use this block:

respond_to do |format| 
  format.**xml** { render :xml => e } 

Otherwise if you change the request to a xml request instead of normal html request, then you can use this:

class ServicesController < ApplicationController

respond_to :html, :xml

def method_name 
@events =