1

How to add the html class name to select box in rails

I have tried following methods but getting syntax error

<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id, html_options={class: 'tst'} %>

<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id,{class: 'tst'} %>


<%= f.collection_select :product, @product, :id, :name, selected: @post.product.id, html_options: {class: 'tst'} %>

Tried all the above three ways but I am unable to fix it how can i add a html class in it.

kndwsu
  • 371
  • 1
  • 8
  • 21
  • Have you checked out the syntax on this previous post? http://stackoverflow.com/questions/1947578/how-do-i-set-the-html-options-for-collection-select-in-rails – emk411 Nov 14 '13 at 18:15
  • @emk411 Yes checked already but that doesn't help – kndwsu Nov 14 '13 at 18:21

1 Answers1

1

i've made something similar work with :class => classname

emk411
  • 177
  • 8