Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image file input with Formtastic and ActiveAdmin

I started to use formstatic but I need to make a file field with image preview. I mean, when i edit an object, i want to see the image already linked.

How can I do that?

Thank you !

like image 977
Sebastien Avatar asked Aug 16 '11 16:08

Sebastien


1 Answers

The answer is to use the hint attribute :

ActiveAdmin.register Event do
  form :html => { :enctype => "multipart/form-data" } do |f|
    f.input :map, :as => :file, :hint => f.template.image_tag(f.object.map.url(:thumb))
  end
end

Bye

like image 57
Sebastien Avatar answered Sep 22 '22 11:09

Sebastien