This question has been answered, but I would like to mention a special case in which the drasbo method drasbo not work.
If you want the attribute to be conditional. Say the verified attribute input[type=checkbox] !
Having a verified attribute makes a difference, and unfortunately browsers tend to ignore its value.
Unfortunately, its not available with HAML syntax. To do this, you need to return to the standard HTML tag:
%form <input type="checkbox" "#{@post.tags.include?("Special Blog")? "checked" : ""}" /> %button Click Me
Annie
source share