2011-02-25 29 views
14

我得到了額外的網址參數做工精細用我的link_to,但無法弄清楚如何使鏈接開放進入邁上了一個新的窗口或標籤rails 3,在link_to中如何指定目標和可選的url參數?

我想:目標=>在好幾個地方「_blank」,但它總是拋出這裏有語法錯誤

是我所指定的目標前:

= link_to "click here", :controller=>"widget", :action=>"mypage", :extraparam => "foobar" 

回答

32

試試這個:

link_to "click here", { :controller=>"widget", :action=>"mypage", :extraparam => "foobar" }, :target => "_blank" 
+0

衛生署!謝謝! – jpwynn 2011-02-25 03:33:27

+0

或者對於「標準」鏈接,「link_to」點擊此處「,」http://what.ever/foo.html「,:target =>」_blank「 – 2012-11-20 13:28:16

相關問題