1
如何添加HTML類名來選擇軌道盒HTML類collection_select
我曾嘗試以下方法,但得到的語法錯誤
<%= 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'} %>
嘗試了上述所有三種方式,但我無法要解決它如何添加一個html類。
你檢查過這篇文章的語法嗎? http://stackoverflow.com/questions/1947578/how-do-i-set-the-html-options-for-collection-select-in-rails – emk411
@ emk411已經檢查過,但沒有幫幫我 – kndwsu