Reputation: 587
I have a boolean value on a task model I want to show the value in a checkbox without the possiblity of changing the checkbox value.
How can I achieve this? Why doesn't my code work?
<%= form_for(@task) do |f| %>
<%= f.check_box :important, {}, disabled="disabled" %>
<% end %>
Thanks in advance.
Upvotes: 0
Views: 790
Reputation: 587
I finally found an easy solution. The check_box_tag or check_box just confused me and I could not call the boolean value related on the checkbox (checked = true, unckecked = false).
This works perfectly:
<%= form_for(@task) do |f| %>
<%= f.check_box :important, :disabled => true %>
<% end %>
Upvotes: 1