rails/rails — Issue #4695: Nested attributes : "TypeError: can't convert String into Integer"
Author: Izanami
Created: 2012-01-26 12:32:48+00:00
State: open

Hello,

I use rails 3.2. When i write in console rails :
Event.create(:busies_attributes => {:name => "ok"})

I have a error :
TypeError: can't convert Symbol into Integer
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/nested_attributes.rb:396:in `[]'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/nested_attributes.rb:396:in `block in assign_nested_attributes_for_collection_association'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/nested_attributes.rb:396:in `map'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/nested_attributes.rb:396:in `assign_nested_attributes_for_collection_association'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/nested_attributes.rb:288:in `busies_attributes='
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/attribute_assignment.rb:94:in `block in assign_attributes'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/attribute_assignment.rb:93:in `each'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/attribute_assignment.rb:93:in `assign_attributes'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/base.rb:488:in `initialize'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/persistence.rb:44:in `new'
from /usr/lib/ruby/gems/1.9.1/gems/activerecord-3.2.0/lib/active_record/persistence.rb:44:in `create'
from (irb):75
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands/console.rb:47:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands/console.rb:8:in `start'
from /usr/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/commands.rb:41:in `'
from script/rails:6:in `require'
from script/rails:6:in `

'

class Event < ActiveRecord::Base
has_many :busies
attr_accessible :name, :content, :busies_attributes
accepts_nested_attributes_for :busies
end

class Busy < ActiveRecord::Base
attr_accessible :start, :end, :all

belongs_to :event
end