In a formtastic form for new products, I am displaying a collection of options for radio buttons which appear as images. I need to pass a data attribute to be used client side.
A product has many images, hence product.product_images is an array of active records. I've tried variations on the code below without success.
<%= f.input :selected_image_url, as: :radio,
collection: (Hash[product.product_images.map { |image| [image_tag(image.thumb), image.image_url], html: {data: {image_huge: image.huge}} }]) %>
the error message is unexpected ',', expecting '}'
The code below gives the error message invalid number of elements (3 for 1..2)
<%= f.input :selected_image_url, as: :radio,
collection: (Hash[product.product_images.map { |image| [image_tag(image.thumb), image.image_url, {"data-image-huge" => image.huge}] }]) %>
Any ideas?
Here's what worked