2
比如我有兩個型號:主動管理覆蓋索引視圖
- 用戶 - 的has_many:帖子
- 後 - belongs_to的:用戶
我需要在索引視圖欄在那裏我可以看到每個用戶的帖子數:
index do
column :id
column :name
column :created_at
column "Posts count", :sortable => "posts.count" do |user|
user.posts.count.to_s
end
default_actions
end
我的問題是:sortable =>「posts.count」不起作用,我收到異常。
你試過了:sortable => false? – 2012-03-28 12:07:00
但是我需要對這一列進行排序,我應該怎麼做? – zolter 2012-03-28 12:08:27
它會告訴你與每個用戶相關的帖子數 – 2012-03-28 12:09:08