1

I'm using Rails and Bootstrap and I'm trying to create large 100x100 pixel buttons with a large image at the top and text below.

I'm using the follwing code in the view (partial):

<button class="btn btn-large btn-vehicles btn-header-maint">
        <%= image_tag ("glyphs/Vehicles.gif" , :size => "66x66") %>
        <br></br>
        <%= link_to( "Vehicles", :controller => 'vehicles') %>
        </button>

The problem is that only the text is working as a link, not the whole button. I've messed around for hours trying to solve this. Can anyone help with the correct structure?

1 Answer 1

1

You can't nest links within <button> tags.

You probably want to just use the link itself as the button, put the content inside it, and style it appropriately:

<%= link_to( "Vehicles", :controller => 'vehicles') do %>
  <%= image_tag ("glyphs/Vehicles.gif" , :size => "66x66") %>
  <br></br>
<% end %>
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks meager that's perfect. final code: '<%= link_to( "Vehicles", :controller => 'vehicles', :class =>"btn btn-large btn-vehicles" ) do %> <%= image_tag ("glyphs/Vehicles.gif" , :size => "48x48") %> <br></br> Vehicles <% end %>
@jared, if this worked for you consider accepting the above answer :)
Thanks meager - first post from a newb

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.