Rails: Disabling link_to link not working but hidden link_to working

Actually there is no disabled attribute available for link_to, only for button_to tag.

For more information please refer here: http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

In this case, you might want to use link_to_if, please have a look into this: http://apidock.com/rails/v4.2.1/ActionView/Helpers/UrlHelper/link_to_if


Probably, you are looking for link_to_if. link_to_if makes your link clickable only if your condition pass.

Your code should be something like:

<%= link_to_if false, edit_cabinet_path(object), remote: true do %>
      <span class="glyphicon glyphicon-pencil"></span>
<% end %> 

To make it dynamic you can call condition that satisfy whether to active or inactive that link, something like:

<%= link_to_if cabinate.active?, 
               "<span class='glyphicon glyphicon-pencil'></span>".html_safe, 
               edit_cabinet_path(object), remote: true %>

Hope this answer your question..