more respond_to strangeness

I'm looking for some debugging tips on this respond_to strangeness. My xml file is being rendered within my html layout.

this is a different problem than the question I posted here: http://groups.google.com/group/rubyonrails-talk/browse_frm/thread/cb835c10fdda3478/8aa485a9333c2e84?lnk=gst&q=respond_to+strangeness&rnum=1#8aa485a9333c2e84 In that problem, rails was not detecting that I had an .rhtml file, when I did. Turned out to be a conflict between respond_to and the globalize_rails plug-in I was using. I have since stripped out globalize functionality.

Here is my controller...

def show    @question = Question.find(params[:id])      respond_to do |type|        type.html        type.js        type.xml         end end

For xml views, I have an show.rxml view for it to render.

The html view works fine, but if I request the page in xml format, the xml view gets rendered properly, but within my html layout!

If I do something like: type.xml {render :xml => @question.to_xml} that xml renders fine. But if I tell it render an .rxml file, it renders my html layout around it.

My development log shows this when I access the xml file: Processing QuestionsController#show (for 127.0.0.1 at 2006-09-11 12:06:48) [GET]   Session ID: de93f56a6915c01446ca0f58e9acf14d   Parameters: {"format"=>"xml", "action"=>"show", "id"=>"7", "controller"=>"questions"}   e[4;35;1mQuestion Columns (0.004284)e[0m e[0mSHOW FIELDS FROM questionse[0m   e[4;36;1mQuestion Load (0.001594)e[0m e[0;1mSELECT * FROM questions WHERE (questions.id = 7) e[0m Rendering actionshow.rxmllayoutfalse within layouts/simple Rendering questions/show.rxml

Okay, it is not just me. Here is a link to someone else having the same issue: http://www.mail-archive.com/sdruby@lists.sdruby.com/msg00057.html

I used Kevin's suggestion which worked. respond_to do |wants|   wants.xml { render :template => 'my_template.rxml', :layout => false } end

But I thought rails would automatically look for an method.rxml file and ignore any method.rhtml file. It seems you have to specify the rxml file however.

It's strange because I thought it was working last week without telling it to specifically render an rxml file.

If it previously found a .rhtml file during the same execution of your application in development mode, it will have cached it, and will continue to serve it even after you've created a new .rxml file. This can lead to some apparently random behavior.

Don't know if this could account for what you're seeing.

Dave