Lumen
Lumen

Reputation: 139

Multiple CSS classes to style a Button w/ Rails and Twitter bootstrap

I'm using Rails 3.1 and Twitter Bootstrap, but struggling to replicate <a class="btn btn-large" href="">Button!</a> with a rails helper.

With the CSS giving providing the 'button', I'm not sure whether I should be using link_to or button_to, but I DO know that neither of them are giving me the appropriately styled button.

I've tried a variety of combinations, for instance:

<%= button_to "Button!", :class => "btn btn-large" %>

How can I replicate my normal HTML link with a rails helper?

Upvotes: 0

Views: 1439

Answers (2)

TimPetricola
TimPetricola

Reputation: 1491

You should use link_to :

<%= link_to 'Button!', '#', :class => 'btn btn-large' %>

I use it in this way and it works perfectly.

The button_to helper generate a form with a button. Here, you just want a link with a button appearance.

Upvotes: 3

P Varga
P Varga

Reputation: 20269

You have to specify multiple classse for a HTML element as <element class="foo bar">, not as <element class="foo" class="bar">. This might seem slightly counter-intuitive, I agree.

Upvotes: 0

Related Questions