我有一个 xml 文件,我想向用户显示(呈现)原样,即我想保留标签。在 RoR 中我应该怎么做?
我试过了render :file=>"/path/to/file.xml"
, 但标签 <product>
消失了。
//file.xml
<product>car</product>
更新:我发现该行为取决于浏览器
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.3) Gecko/2008101315 Ubuntu/8.10 (intrepid) Firefox/3.0.3
标签保留。
Mozilla/5.0(Windows;U;Windows NT 5.1;zh-CN;rv:1.9.0.15)Gecko/2009101601 Firefox/3.0.15
标签消失了。
最佳答案
你试过添加吗
:content_type => 'application/xml'
到你的渲染线?
render :file=>"/path/to/file.xml", :content_type => 'application/xml'
关于ruby-on-rails - 如何在 RoR 中向用户显示现有的 xml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1845866/