Rails Haml复选框

时间:2012-01-11 18:00:43

标签: ruby-on-rails haml

愚蠢的问题,我怎么能用haml重写我的代码?

<% for role in Role.find(:all) %>
<div>
  <%= check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role) %>
  <%= role.name %>
</div>
  

我可以在哪里找到haml示例,例如http://apidock.com/rails/ActionView/Helpers/FormTagHelper/check_box_tag 谢谢!

2 个答案:

答案 0 :(得分:11)

- for role in Role.find(:all)
  %div
    = check_box_tag "user[role_ids][]", role.id, @user.roles.include?(role)
    = role.name

我刚刚使用了http://html2haml.heroku.com/

答案 1 :(得分:0)

也许为时不晚,但总是可以运行html2haml命令。类似于:html2haml app/views/layout/application.html.erb app/views/layouts/application.html.haml