【问题标题】:Rails Haml checkboxRails Haml 复选框
【发布时间】:2012-01-11 18:00:43
【问题描述】:

愚蠢的问题,我如何用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 谢谢!

【问题讨论】:

    标签: ruby-on-rails haml


    【解决方案1】:
    - 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/

    【讨论】:

      【解决方案2】:

      也许还不算太晚,但您总是可以运行html2haml 命令。比如:html2haml app/views/layout/application.html.erb app/views/layouts/application.html.haml

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-05-19
        • 1970-01-01
        • 1970-01-01
        • 2016-05-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多