Search code examples
ruby-on-railsruby-on-rails-4link-to

link_to block not working


I'm using a series of link_to blocks to create buttons in my application. However I'm finding that these links don't end up working. As I mouse-over the button, it recognizes the link, the correct url displays in the lower left-hand corner in firefox, but when I click, nothing happens. Nothing comes up in my terminal or development log either.

My code is as follows:

<%= link_to new_folder_path do%>
    <div class="btn btn-default add-button add_fields"><span class="glyphicon glyphicon-plus"></span>Add Folder</div>
<% end %>

This renders the following html:

<li>
  <a href="/folders/new">
    <div class="btn btn-default add-button add_fields"><span class="glyphicon glyphicon-plus"></span>Add Folder</div>
  </a>
</li>

I should also note that if I just type the standard link in without the do block, it runs just fine:

<li><%= link_to "test", new_folder_path %></li>

Any thoughts on this would be much appreciated!


Solution

  • Turned out I had dropped a class into my div that prevented the link from rendering (add_fields was the class). Profoundly unsatisfying answer it is what it is. Thanks to anyone who took the time to give me a hint.