# Respond\_to strangeness

**URL:** <https://www.ruby-forum.com/t/respond-to-strangeness/67299>\
**Category:** Rails\
**Created:** [September 1, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299 "2006-09-01T23:47:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 1, 2006, 11:47pm UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/1 "2006-09-01T23:47:44Z")

</div>

Hi, I’m in the process of RESTifying my site. Almost there and loving  
it.

I started having this strange problem today.

In my controller if I have something like…

def show  
@question = Question.find(2)  
end

…it displays my show.rhtml file with no problems.

If if change it to this…  
class QuestionsController  
def show  
@question = Question.find(2)  
respond\_to do |type|  
type.html  
type.js  
type.xml { render :xml =\> @question.to\_xml }  
end  
end

…then it starts throwing a “No rhtml, rxml, rjs or delegate template  
found for questions/show.rhtml”

But it will successfully show questions/2.xml in xml format.

I can get the html to work if I change the type.html line to:  
type.html { render :action =\> ‘show’}

My dev log doesn’t give me any clues. Any ideas?

Thanks,

Steve O.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 2, 2006, 12:05am UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/2 "2006-09-02T00:05:45Z")

</div>

Hi Steve,  
You did define a response for a request in the xml format and you  
should be doing the same thing for the html request which you are doing  
in the second case by rendering the show view.  
Uma

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 2, 2006, 12:27am UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/3 "2006-09-02T00:27:46Z")

</div>

I was under the impression that I didn’t have to do define a response  
like:  
type.html { render :action =\> ‘show’ }

that just “type.html” is enough as long as I have the show.rhtml file  
in my view.

What is wierd is that “type.html” was working fine without render  
instructions until earlier today when I started focusing on building an  
xml view.

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 2, 2006, 1:21am UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/4 "2006-09-02T01:21:49Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I was under the impression that I didn’t have to do define a response  
> like:  
> type.html { render :action =\> ‘show’ }
> 
> that just “type.html” is enough as long as I have the show.rhtml file  
> in my view.
> 
> What is wierd is that “type.html” was working fine without render  
> instructions until earlier today when I started focusing on building an  
> xml view.

Yes you are right, the default action is to call the render method. It  
still brings us to your initial issue though.  
So you currently have both the .rhtml as well as the .rxml views for  
the action I assume.  
and how do you send the xml request ?  
Try to remove the type.xml and see if it behaves the same way.  
I am not sure of any other particular reason though…

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 2, 2006, 1:41am UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/5 "2006-09-02T01:41:50Z")

</div>

> So you currently have both the .rhtml as well as the .rxml views for  
> the action I assume.  
> yep, both are in my questions view directory

> and how do you send the xml request ?

I was just adding .xml to the url (ie localhost:3000/questions/56.xml )

> Try to remove the type.xml and see if it behaves the same way.

I tried that. As long as I have respond\_to … and no explicit render  
instructions next to type.html then I’ll get an error - despite the  
show.rhtml file being available.

> I am not sure of any other particular reason though…

It’s puzzling. thanks for your help.

Steve

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [September 11, 2006, 1:36pm UTC](https://www.ruby-forum.com/t/respond-to-strangeness/67299/6 "2006-09-11T13:36:03Z")

</div>

Solved. It was my globalize-rails plugin that was screwing up the  
respond\_to.
