1

在使用 ActiveAdmin 的 Rails 应用程序中,我的一个字段是在一个非常窄的列中打印大量文本,并导致单个 db 行垂直占据整个屏幕。如果超过,我只希望 ActiveAdmin 显示带有省略号的前 50 个字符。

index do
  column :too_long
...

我正在寻找这样的东西

index do
  column :too_long, :max => 50
...
4

2 回答 2

4

您也可以truncate为此使用辅助函数

index do
   id_column
   column :too_long do |my_resource|
      truncate(my_resource.too_long, length: 50)
   end
   actions
end
于 2015-04-22T09:49:47.317 回答
3

你可以使用类似的东西

 index do
   column "TOO LONG" do |object|
      object.too_long.slice(0, 50)
   end
  #.....
 end

我还没有测试过这个,但是这样的东西应该可以工作。

在文档http://activeadmin.info/docs/3-index-pages/index-as-table.html中查看更多详细信息

于 2012-08-11T14:09:46.687 回答