0

I'm using bootstrap on rails and struggling to figure out how to attach a link to a button so that it opens a web address in a new tab.

The code is:

<%= link_to "Learn more about the Royal Lancers»", "#", class: "btn btn-primary btn-lg" %> 

I'm trying to link the button in a new tab to

"https://www.army.mod.uk/who-we-are/corps-regiments-and-units/royal-armoured-corps/royal-lancers/"

Otis
  • 3
  • 1

2 Answers2

0

This is covered in How to use "_blank" or "_new" in Rails; adding target: '_blank' opens the link in a new tab.

<%= link_to "Learn more about the Royal Lancers»", "#", class: "btn btn-primary btn-lg", target: '_blank'%> 
Boucherie
  • 541
  • 4
  • 20
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" %> 
Otis
  • 3
  • 1