我在导轨上使用引导程序,并努力找出如何将链接附加到按钮,以便它在新选项卡中打开网址。
代码是:
<%= link_to "Learn more about the Royal Lancers»", "#", class: "btn btn-primary btn-lg" %>
我正在尝试将新标签中的按钮链接到
“ https://www.army.mod.uk/who-we-are/corps-regiments-and-units/royal-armoured-corps/royal-lancers/”
答案 0 :(得分:0)
这在How to use "_blank" or "_new" in Rails中涉及;添加target: '_blank'
会在新标签页中打开链接。
<%= link_to "Learn more about the Royal Lancers»", "#", class: "btn btn-primary btn-lg", target: '_blank'%>
答案 1 :(得分:0)
This worked:
<%= link_to "The Royal Lancers »", "https://www.army.mod.uk/who-we-are/corps-regiments-and-units/royal-armoured-corps/royal-lancers/", target: '_blank', class: "btn btn-primary btn-lg" %>