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'}
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
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...
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...