2009-11-09 25 views
6

Bir ray uygulaması içinde bazı link_to xml görünümleri ayarlıyorum. URL, .xml uzantısını nasıl görüntüleyebilir?URL'ye uzantı ekleniyor: Raylar

Need it to appear as: 
http://localhost:3000/test/1-testing.xml 

Currently it appears as: 
http://localhost:3000/test/1-testing 

cevap

0

Eğer örnek @test bağlamak istediğiniz varsayarak, deneyin:

test_url(@test, :format => :xml) 
+0

Bu benim olduğu bağlantı kodu: <% = link_to 'Harita', {: action => 'map',: id => giriş,: format =>: xml}%> Ve şu şekilde görüntülenir: http: // localhost: 3000/entries/map/1-sample-form? Format = xml Ve olması gereken: http: // localhost: 3000/entries/map/1-sample-form.xml – Jeffrey

10

Raylar 3'te Yolunuz foo_path olduğunu varsayarak, o zaman istiyorum: Bir de

foo_path(:format=>:xml) 

link_to,

Ve daha seçenekleri:

link_to "link text", foo_path(:format => :xml), :id=>"foo_id", :class=>"foo_class" 

(. Bu soru halt kadar eski, ama benim yaptığım gibi ben Google aracılığıyla bu bulan kişinin yardım etmek cevap düşündüm)