【问题标题】:Formtastic hint issue (unwanted object ID output) in ActiveAdminActiveAdmin 中的 Formtastic 提示问题(不需要的对象 ID 输出)
【发布时间】:2014-12-27 14:03:43
【问题描述】:

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

#:0x00000006bd1018>

  • 为什么会从类似 obj.inspect 的结果开始,以及如何删除这部分?

    导致此错误的代码在这里:

    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
    

    【问题讨论】:

    • 你能发布更多你的资源文件吗?这是 ActiveAdmin 表单块还是其他地方的部分?

    标签: ruby-on-rails ruby paperclip activeadmin formtastic


    【解决方案1】:

    这应该可行:

    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
    

    【讨论】:

    • 这看起来和问题中的代码一模一样,你能解释一下你改变了什么吗?
    • 好吧,不同的是,去掉 f。和模板的东西
    【解决方案2】:

    试试看。

        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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-08-17
      相关资源
      最近更新 更多