How do I add a data attribute to a Rails radio_button?

ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2

Solution

Try this: `"data-product-id" => product_id`

Problem

I'm trying to do this in a helper: ``` def radio_button_by_code(da_form, da_field, product_id, option_code) txt = Product.find(product_id).options.find_by_code(option_code).title btn = da_form.radio_button(da_field, txt, :data-product-id => product_id) "<label>#{btn} #{txt}</label>".html_safe end ``` But, if I do that, I always get a undefined local variable or method `product' error. If I remove the :data-product-id => product_id part, then it outputs the radio button correctly. How can I add the data attribute to the radio_button?

Original source