Why is respond_to always rending the RXML view?

I’m having a problem in Rails 2 where respond_to is always rendering the
RXML view even in the HTML rendering response. Can anyone tell me why
this might be happening? Here’s a code snippet:

respond_to do |accepts|
accepts.html
accepts.xml { render :action => ‘show.rxml’, :layout => false}
end

If I change this to the following it works fine:

respond_to do |accepts|
accepts.html { render :action => ‘show.rhtml’, :layout => true }
accepts.xml { render :action => ‘show.rxml’, :layout => false }
end

Here’s my setup:

rails (2.0.2)
mongrel (1.1.4)
mongrel_cluster (1.0.5)
apache (2.2.6)

Thanks in advance!

  • Jason

On Sun, Apr 20, 2008 at 2:38 PM, Jason F.
[email protected]
wrote:

accepts.html { render :action => ‘show.rhtml’, :layout => true }
accepts.xml { render :action => ‘show.rxml’, :layout => false }
end

The only idea I have is that maybe you don’t need to use render :action.
Instead, maybe you should be getting some XML from somewhere (such as
calling #to_xml on a model or collection) and rendering it like this?

respond_to do |accepts|
accepts.html
accepts.xml { render :xml => some_model.to_xml }
end

See also:
http://www.railsbrain.com/api/rails-2.0.2/doc/index.html?a=M000211&name=respond_to

Regards,
Craig

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs