2013-05-30 36 views
0

我試圖從模型中的值打印並顯示「多個」可選擇的列表。導軌在fields_for中選擇,將數字計數爲數值DB

 <%= f.fields_for :blackwhite do |blackwhite| %> 
      <div class="span6"><p class="muted text-right">Black and White</p></div> 
      <%= blackwhite.select :newpage, options_for_select((1..number_of_images_entry).to_a), { :multiple => true }) %> 
     <% end %> 

並不太瞭解

http://railsforum.com/viewtopic.php?id=6716

我想從版畫表(當前視圖),對於具有整數值計數到「number_of_images_entry」列中的值,從1開始 - 我使用這裏的示例:

how to build a select tag from a range in rails

:NEWPAGE是在一列「黑白」表。 (這是另一張桌子)

謝謝!

編輯:

的代碼是從數據庫中獲取的值了,但多選無效。

<%= blackwhite.select :newpage, options_for_select((1..(@print.number_of_images_entry)).to_a), { :multiple => true } %> 

回答

0

請更正您的代碼。

<%= blackwhite.select :newpages, options_for_select((1..(@print.number_of_images_entry)).to_a), {} ,multiple: true %> 
+0

更正了我的代碼。 – muhammadn

+0

代碼正在從數據庫中獲取數據,但是多個選擇不起作用。 – muhammadn

+0

我編輯了代碼。請查看更改。它的工作原理是 –