ActiveAdmin中的Formtastic提示问题(不需要的对象ID输出)

时间:2021-07-02 16:00:33

When I use formtastic DSL for ActiveAdmin edit form I get the following output:

当我为ActiveAdmin编辑表单使用formtastic DSL时,我得到如下输出:

#< #< Class:0x00000006bd1f68>:0x00000006bd1018> <li class="file input optional" id="post_image_input"><label class="label" for="post_image">Image</label><input id="post_image" name="post[image]" type="file" />

< span lang = en - us style = ' font - size: 9.0 pt; font - family:宋体;mso - ascii - font - family: tahoma

Why does this starts from something like result of obj.inspect and how to remove this part?

为什么这是从obj的结果开始的。检查并如何去掉这部分?

The code, causing this bug is here:

导致此错误的代码如下:

form :html => { :multipart => true } do |f|
    f.inputs do
        #...
        f.input :image, required: false, hint: f.template.image_tag(f.object.image.url(:medium)).html_safe
        #...
    end
    f.actions
end

2 个解决方案

#1


8  

This should work:

这应该工作:

form :html => { :multipart => true } do |f|
    f.inputs do
        #...
        f.input :image, required: false, hint: image_tag(object.image.url(:medium)).html_safe
        #...
    end
    f.actions
end

#2


1  

Try it.

试一试。

form :html => { :multipart => true } do |f|
    f.inputs do
        #...
        f.input :image, required: false, :hint => image_tag(f.object.image.url(:medium))
        #...
    end
    f.actions
end

#1


8  

This should work:

这应该工作:

form :html => { :multipart => true } do |f|
    f.inputs do
        #...
        f.input :image, required: false, hint: image_tag(object.image.url(:medium)).html_safe
        #...
    end
    f.actions
end

#2


1  

Try it.

试一试。

form :html => { :multipart => true } do |f|
    f.inputs do
        #...
        f.input :image, required: false, :hint => image_tag(f.object.image.url(:medium))
        #...
    end
    f.actions
end