Formtastic hint issue (unwanted object ID output)

2019-07-24 13:56发布

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

#< #< 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" />

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

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条回答
等我变得足够好
2楼-- · 2019-07-24 14:41

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
查看更多
该账号已被封号
3楼-- · 2019-07-24 14:48

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
查看更多
登录 后发表回答