Cutsom 输入格式,我做错了什么?
我为 formtastic 制作了一种自定义输入法,它被设计为与 Carrierwave 一起使用,并且效果很好,但有一个例外,预览图像和其他 html 不会呈现,因为它正在被清理(我认为)。
我的处理方式完全错误吗?
这是代码:
def carrierwave_input(method, options)
c = basic_input_helper(:file_field, :string, method, options)
c += hidden_input((method.to_s+"_cache").to_sym, {})
if object.send("#{method.to_s}?")
c += %{<img src="#{object.send("#{method.to_s}_url")}">}
c += "<br>"
c += boolean_input(("remove_"+method.to_s).to_sym, {})
end
return c
end
call with:
form.input :thumb, :as => :carrierwave
渲染图像时,
标签被转义。
我该如何解决这个问题。
非常感谢
I have made a custom input method for formtastic, it is designed to work with carrierwave and it works great but with one exception, the preview image and other html will not render, as it is being sanitized (i think).
Am i going about this completely the wrong way?
Here is the code:
def carrierwave_input(method, options)
c = basic_input_helper(:file_field, :string, method, options)
c += hidden_input((method.to_s+"_cache").to_sym, {})
if object.send("#{method.to_s}?")
c += %{<img src="#{object.send("#{method.to_s}_url")}">}
c += "<br>"
c += boolean_input(("remove_"+method.to_s).to_sym, {})
end
return c
end
calling with:
form.input :thumb, :as => :carrierwave
when rendered the image and
tags escaped.
how can i get round this.
many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是在 Rails 3 上吗?如果是这样,请尝试调用“return c.html_safe”
Is this on rails 3? If so, try calling "return c.html_safe"