Formtastic hint issue (unwanted object ID output) in ActiveAdmin

梦想的初衷 提交于 2019-12-11 01:35:34

问题


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

回答1:


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:


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


来源:https://stackoverflow.com/questions/27667966/formtastic-hint-issue-unwanted-object-id-output-in-activeadmin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!