6
我在Rails應用中設置了一些link_to xml視圖。 url如何顯示.xml擴展名?向URL添加擴展:Rails
Need it to appear as:
http://localhost:3000/test/1-testing.xml
Currently it appears as:
http://localhost:3000/test/1-testing
我在Rails應用中設置了一些link_to xml視圖。 url如何顯示.xml擴展名?向URL添加擴展:Rails
Need it to appear as:
http://localhost:3000/test/1-testing.xml
Currently it appears as:
http://localhost:3000/test/1-testing
假設你要鏈接到該實例@test,請嘗試:
test_url(@test, :format => :xml)
在Rails 3,假設你的路徑是foo_path
,然後你想:
foo_path(:format=>:xml)
在link_to
,你可以做
link_to "link text", foo_path(:format => :xml)
點
而且具有更多的選擇:
link_to "link text", foo_path(:format => :xml), :id=>"foo_id", :class=>"foo_class"
(這個問題是老赫克,但我想我會回答,以幫助任何人誰通過谷歌發現這一點,像我一樣)
這是我的鏈接代碼: <%= link_to'Map',{:action =>'map',:id => entry,:format =>:xml}%> 並顯示爲: http:// localhost: 3000/entries/map/1-sample-form?format = xml 它需要是: http:// localhost:3000/entries/map/1-sample-form.xml – Jeffrey 2009-11-09 18:41:09