I’m using Rails 4.2. I want to disable a button and render it unclickable in my ERB, subject to certain conditions. I tried this
<%= link_to 'Submit Form', order_products_path, method: :post, data: {confirm: "Are you sure?"},
class: 'btn btn-class1', disabled: submit_disable %>
And although the button on the UI appears as disabled, it is still clickable (when I click on it, the "Are you sure?" confirmation appears). So then I tried this
<%= link_to_if !submit_disable, 'Submit Form', order_products_path, method: :post, data: {confirm: "Are you sure?"},
class: 'btn btn-class1', disabled: submit_disable %>
However now the button appears only as text. What’s the proper way to disable a button and eliminate the ability for a user to click on it?
link_to_ifwill return only name if the condition is false, however you could pass a block as falsy case, so, i think you could do like so