How to add data attribute for options_from_collection_for_select in rails

Viewed 6867

Consider this as my select tag

<%= select_tag "post[brand_slug]", options_from_collection_for_select(@products, 'slug', 'name'), prompt: 'select' %>

This works fine but I need a data attribute

<%= select_tag "post[brand_slug]", options_from_collection_for_select(@products, 'slug', 'name'), data: {id: @products.id} , prompt: 'select' %>

@product.id is not working. How can I get the ID too

1 Answers
Related