0

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Note: if JavaScript is disabled, this solution does not work for other methods than GET.
0

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.

1 Comment

Thanks, for the answer, but it's the Rails helper version of this that I can't get working. :) I'll edit the question to reflect the proper HTML syntax.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.