mcadamsjustin
mcadamsjustin

Reputation: 361

Make button a link to PDF file with Bootstrap

I'd like to link a pdf to a button using the bootstrap framework in Rails. For example the button would say download now and link to the PDF. I'm not concerned on how the PDF opens, just that it links to it.

In the Bootstrap documentation it says to use only the <a> tag and it doesn't mention anything about the <%= link_to %> tag. This is what's listed in the Bootstrap doc's <a class="btn btn-large btn-danger" href="#">Download Now</a>, where "Download Now" is the text show on the button.

Any help is appreciated.

Upvotes: 3

Views: 12900

Answers (1)

Bogdan Rybak
Bogdan Rybak

Reputation: 2117

You can specify class as one of the arguments of link_to

<%= link_to "Download Now", '/path/to/file/or/path_method', :class => "btn btn-large btn-danger" %>

or

<%= link_to '/path/to/file/or/path_method', :class => "btn btn-large btn-danger" do %>
  Download Now
<% end %>

Rails Framework Documentation for link_to

Upvotes: 4

Related Questions