Rails upgrade: rxml file rendered instead of haml file
I'm upgrading an old Rails 1.x app to 2.3.10, and I'm running into a problem with rendering views. I have a controller that has two views associated with it: index.haml
and index.rxml
. Before the upgrade everything worked a开发者_开发百科s expected. After moving to Rails 2, the same code (with no changes) has started automatically rendering the XML view at the end of the wants.html
block, when it should be rendering the haml view. When I rename the index.rxml
file to something else (like foo.rxml
), it successfully finds and renders the index.haml
file.
What changed in the view rendering logic from Rails 1 to Rails 2 that is causing this?
I haven't worked with Rails 1 (jumped in at Rails 2), but I guess it's because Rails 2 uses .html.erb instead of .rhtml. Same goes for .xml.erb instead of .rxml. And the same thing has happened for HAML: .haml becomes .html.haml. Don't know if this is the thing causing your problem, but it's the Rails 2 way of creating views.
EDIT
Also, if you want to render XML in Rails 2, you need to add the following to your Controller:
respond_to do |format|
format.xml { render :xml_view_name }
end
精彩评论