2012-06-15 22 views
3

我使用carrierwave gem上傳圖像到我的應用程序。
現在我需要在一個表單的下拉列表中顯示圖像。我試圖使用msDropDown。但是,我需要在我的<select>的每個<option>內生成title="#path for the image"
目前我有:生成HTML <select>標題內每個<option>應用msDropDown插件

<%= f.select(:style_id, Style.all.map{ |p| [p.dropdown, p.id] }, {:include_blank => 'Select Style | Construction'}, class: "bigselect") %> 

上述生成以下HTML:

<select class="bigselect" id="item_style_id" name="item[style_id]"><option value="">Select Style | Construction</option> 
    <option value="1">first</option> 
    <option value="2">second</option> 
    ... 
</select> 

我需要修改我的回報率選擇代碼生成下面的HTML。

<select class="bigselect" id="item_style_id" name="item[style_id]"><option value="">Select Style | Construction</option> 
    <option value="1" title="#path for the image">first</option> 
    <option value="2" title="#path for the image">second</option> 
    ... 
</select> 

#path for the image是在同一個模型上我選擇了dropdown列的列image。所以,使用carrierwave應該是類似於p.image_url(:thumb)
任何想法如何產生這title
非常感謝。

回答

3

試圖通過標題爲html選項<option>元素

<%= f.select(:style_id, Style.all.map{|p| [p.name, p.id, :title => p.image_url(:thumb)]}, .... 
+0

你救了我的一天......非常感謝 – gabrielhilal