Rails 2.3.5,Ruby 1.86Fixnums as symbols來自collection_select的警告
我不是很理解這個警告。當@directories
在collection_select
中使用時,我收到@directories
中包含的每條記錄的警告。我試過玩弄:id
實例,但是運行方式不同,但沒有運氣。我相信這很簡單(我還是很新的)。
在此先感謝!
錯誤:
C:/Ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:328:
warning: do not use Fixnums as Symbols
違規代碼:
<% if !params[:directory].nil? %>
<%= collection_select :directory, :id, @directories, (:id).to_i, :name,
{:selected => params[:directory][:id].map{|id|id.to_i}}, {:size => 7, :multiple => true} %>
<% else %>
<%= collection_select :directory, :id, @directories, (:id).to_i, :name,
{:selected => @directory_ids}, {:size => 7, :multiple => true} %>
<% end %>
@collections是什麼樣的? (@ collections.inspect) – 2011-01-25 15:01:28