formtastic: radio button collection image_tag

49 views
Skip to first unread message

alexander ryder

unread,
Jun 16, 2014, 3:04:28 AM6/16/14
to rubyonra...@googlegroups.com
Hello,

I would like to ask, how am I going to integrate an image tag during edit on formtastic for a collection of array of images?

  form do |f|                         
    f.inputs "Building" do       
      f.input :name                                                 
      f.input :image,  :as => :radio , :collection => Dir.glob("public/img/buildings/*")
    end                               
    f.actions                         
  end 

Thank you in advance,

Alex

Alex Ryder

unread,
Jun 16, 2014, 4:50:17 AM6/16/14
to rubyonra...@googlegroups.com
 images = Hash.new
  Dir.glob("public/img/buildings/*").each do |s|
    s.gsub!("public/img/buildings/", "")
    images["<img src='/img/buildings/".html_safe + s + "'>".html_safe] = s
  end 

 form do |f|                         
    f.inputs "Building" do       
      f.input :name                                                 
      f.input :image,  :as => :radio , :collection => images
    end                               
    f.actions                         
  end 
Reply all
Reply to author
Forward
0 new messages