如何在ActiveAdmin中显示持久图像?

时间:2018-03-11 03:05:41

标签: ruby-on-rails activeadmin

当显示update表单时,ActiveAdmin会自动提取对象的持久信息。虽然它没有显示图像 - 甚至没有在我的表单中显示名称 - 我如何解决此问题以显示实际图像及其名称?

ActiveAdmin.register Art do

permit_params :art_pic_attachments_attributes: [:id, :picture, :_destroy]

 form(html: { multipart: true }) do |f|
    f.inputs do

        f.has_many :art_pic_attachments, allow_destroy: true, heading: 'Images' do |ff|
            ff.file_field :picture, required: true, heading: "Pictures"
        end

    end
        f.actions
 end 

1 个答案:

答案 0 :(得分:0)

也许this wiki article会有所帮助。关键是使用图像标记作为输入提示。

private void initTable() {
    TableColumn tableColumn = null;
    ButtonGroup group = new ButtonGroup();
    for (int i = 0; i < searchResultTable.getColumnCount(); i++) {
        tableColumn = searchResultTable.getColumnModel().getColumn(i);
        if (i == 0) {// check box
            tableColumn.setMaxWidth(40);
            RadioButtonCellEditorRenderer radioButtonCellEditorRenderer = new RadioButtonCellEditorRenderer();
            group.add(radioButtonCellEditorRenderer.getRadioButton());
            tableColumn.setCellEditor(radioButtonCellEditorRenderer);
            tableColumn.setCellRenderer(radioButtonCellEditorRenderer);
        }
    }
}