Forum: Ruby on Rails formtastic: radio button collection image_tag

693f7cc2d5208871b52b90e70b7854bd?d=identicon&s=25 alexander ryder (Guest)
on 2014-06-16 09:15
(Received via mailing list)
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
693f7cc2d5208871b52b90e70b7854bd?d=identicon&s=25 Alex Ryder (Guest)
on 2014-06-16 10:51
(Received via mailing list)
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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.