开发者

Cutsom Input for formtastic, what am i doing wrong?

I have made a custom input method for formtastic, it is d开发者_StackOverflowesigned 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


Is this on rails 3? If so, try calling "return c.html_safe"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜