ruby-on-railsrubyformsformtasticactiveadmin

Image file input with Formtastic and ActiveAdmin


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

How can I do that?


Solution

  • 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