views:

225

answers:

1

I have Rails 3 application (running Rails RC1), and I have the following controller:

class PluginsController < ApplicationController
  respond_to :html, :xml, :json

  def index
    @plugins = Plugin.all
    respond_with(@plugins)
  end
end

If I try to render http://localhost:3000/plugins it works fine, showing me the HTML version. If I try to get http://localhost:3000/plugins.json, it also correctly sends me the JSON response.

However if I try http://localhost:3000/plugins.xml, I get the following error:

Template is missing

Missing template plugins/index with {:locale=>[:en, :en], :formats=>[:xml], 
:handlers=>[:rjs, :haml, :erb, :rhtml, :builder, :rxml]} in view paths 
"/Users/fcoury/Projects/backend/app/views", 
"/Users/fcoury/Projects/backend/vendor/plugins/haml/app/views", 
"/Users/fcoury/.rvm/gems/ree-1.8.7-2010.01@rails3/bundler/gems/
   devise-6754ae7/app/views"

Also, my ApplicationController is pretty simple:

class ApplicationController < ActionController::Base
  protect_from_forgery
  layout 'application'
end

I have tried taking out the layout line from the control, but same result.

Don't know if it's relevant, but I am using HAML and I only have one view file called plugins/index.html.haml.

Any ideas why this may be happening?

A: 

From the comment to the respond_with method:

When a request comes with format :xml, the respond_with will first search for a template as person/index.xml, if the template is not available, it will see if the given resource responds to :to_xml.

If neither are available, it will raise an error.

Try to explicitly call @plugins.to_xml and investigate the output of it.

floatless