ruby on rails - Fixnums as Symbols Warning from collection_select -


rails 2.3.5, ruby 1.86

i'm not understanding warning. i'm getting 1 warning each record containted in @directories when using @directories in collection_select. i've tried playing around :id instances using them differently no luck. i'm sure it's simple (i'm still pretty new).

thanks in advance!

error:

c:/ruby186/lib/ruby/gems/1.8/gems/actionpack-2.3.5/lib/action_view/helpers/form_options_helper.rb:328:

warning: not use fixnums symbols

the offending code:

<% 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 %> 

you're passing in (:id).to_i argument collection_select. collection_select uses argument send. since (:id).to_i integer , send being called integer argument mistake, send emits warning get.

it should noted there no reason use :id.to_i instead of :id here since difference between send(:symbol) , send(:symbol.to_i) latter produces warning.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -