Ruby on rails 如何干燥引导视图

Ruby on rails 如何干燥引导视图,ruby-on-rails,twitter-bootstrap,haml,Ruby On Rails,Twitter Bootstrap,Haml,我正在寻找一种更好的方法来有效地干燥使用Bootstrap3.0的Rails视图 以下是视图的HAML代码: %h1 Profiles .visible-xs %table.table.table-striped %tbody - @profiles.each do |profile| %tr %td = profile.name %td{style: "text-align: right"

我正在寻找一种更好的方法来有效地干燥使用Bootstrap3.0的Rails视图

以下是视图的HAML代码:

%h1 Profiles

.visible-xs
  %table.table.table-striped
    %tbody
      - @profiles.each do |profile|
        %tr
          %td
            = profile.name
          %td{style: "text-align: right"}
            =link_to "<i class='fa fa-eye fa-small'></i>".html_safe, setup_profile_path(profile), class: "btn"
            =link_to "<i class='fa fa-edit fa-small'></i>".html_safe, edit_setup_profile_path(profile), class: "btn"

.hidden-xs
  %table.table
    %tr
      %th Name
      %th Last Updated
      %th Actions
    - @profiles.each do |profile|
      %tr
        %td= profile.name
        %td= time_ago_in_words profile.updated_at
        %td
          =link_to "<i class='fa fa-eye fa-small'></i> Details".html_safe, setup_profile_path(profile), class: "btn btn-sm"
          =link_to "<i class='fa fa-edit fa-small'></i> Change".html_safe, edit_setup_profile_path(profile), class: "btn btn-sm"
          =link_to "<i class='fa fa-trash-o fa-small'></i> Remove".html_safe, setup_profile_path(profile, method: :destroy), class: "btn btn-sm"
正如你所看到的,我现在有一个额外的栏,可能会为更大的视口添加两个或三个栏,因此随着应用程序的开发,会有一个表格布局,但对于移动设备,我只显示配置文件名称和按钮,以获得更多细节,这在小屏幕上非常实用


我尝试使用网格系统的行和列,但要在每个视口大小下获得一个可用的界面需要做大量的工作,而且当所有这些都在一个视口中时,模板代码看起来就像一个大泥球。到目前为止,分离成XS和其他所有东西是最干净的实现,但是两个块和两个循环可以显示相同的数据。在我开始创建另外20个之前,是否有一种更简单的方法来实现移动xs与平板电脑/台式机sm、md、lg。。。查看和理解仍然非常清晰的视口?

您可以查看单元格,这有助于重构视图代码。请详细说明。a查看单元格对我来说是希腊语。请查看cells.rubyforge.org/