1

ActiveRecord クエリがあるとしましょう:

User.select('name', 'created_at').all
=> [#<User created_at: "2012-08-06 13:27:40", name: "Alice">, #<User created_at: "2012-08-06 15:41:33", name: "Bill">]

列ごとに行スパンを持つソート可能なテーブルを表示するにはcreated_at?

期待される出力 html:

   <table>
      <tr>
          <th>created_at</th>
          <td>name</td>
      </tr>
      <tr>
          <td>2012-08-06</td>
          <td>Alice</td>
      </tr>
      <tr>
          <td>2012-08-06</td>
          <td>Bill</td>
      </tr>   
  </table>
4

1 に答える 1

0

ドキュメントを読む必要があります: http://activeadmin.info/docs/3-index-pages/index-as-table.html

最新バージョン (0.5.1) を使用していると仮定します。

index do
  column "created_at", :sortable => :created_at do |user|
    user.created_at.strftime('%Y-%m-%d') # if the format is different that expected
  end
  column "name", :sortable => :name do |user|
    user.name
  end
end
于 2013-03-11T12:09:37.883 に答える