sadaf2605 sadaf2605 - 2 years ago 143
Ruby Question

activeadmin formtastic f.template.image_tag(...) showing an extra hash at form

At active admin, I have this following code:

ActiveAdmin.register Item do

permit_params :name, :description, :avatar

form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs do
f.input :name
f.input :description

f.input :avatar, :as => :file , :hint => f.template.image_tag(f.object.avatar.url(:medium))


It shows a class hash at the form,unwanted hash demo


<fieldset class="inputs"><ol><li class="string input optional stringish" id="item_name_input"><label for="item_name" class="label">Name</label><input id="item_name" type="text" name="item[name]">

</li><li class="text input optional" id="item_description_input"><label for="item_description" class="label">Description</label><textarea rows="20" id="item_description" name="item[description]"></textarea>

</li>#&lt;#&lt;Class:0x007fb884ba0970&gt;:0x007fb886102b38&gt;<li class="file input optional" id="item_avatar_input"><label for="item_avatar" class="label">Avatar</label><input id="item_avatar" type="file" name="item[avatar]">

<p class="inline-hints"><img src="/images/medium/missing.png" alt="Missing"></p></li></ol></fieldset>

What am I doing wrong here?

Answer Source

Change your code to hint: image_tag(f.object.avatar.url(:medium)).html_safe, f.template is excess here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download