我在这里阅读了有关此错误的其他几篇文章,但没有人真正适合我的问题。
产生的错误是
ActiveRecord::UnknownAttributeError: unknown attribute: practice_id
当我尝试在 rails 控制台中构建 uebung_maps 时,它正在发生:
irb(main):003:0> @p = Practice.new
=> # Practice id: nil, datum: nil, start: nil, end: nil, group: nil, topic: nil, theoab: nil, pracab: nil, action: nil, water: nil, tools: nil, broken: nil, toolkeeper: nil, atw: nil, atfinfo: nil, created_at: nil, updated_at: nil>
irb(main):004:0> @p.uebung_maps.build
ActiveRecord::UnknownAttributeError: unknown attribute: practice_id
from /home/basti/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/attribute_assignment.rb:88:in `block in assign_attributes'
我的模型等看起来如下
实践模式
class Practice < ActiveRecord::Base
has_many :uebung_maps
has_many :persons
accepts_nested_attributes_for :uebung_maps
attr_accessible :uebung_map_attributes, :action, :atfinfo, :atw, :broken, :datum, :end, :group, :pracab, :start, :theoab, :toolkeeper, :tools, :topic, :water
end
Uebung_map 模型
class UebungMap < ActiveRecord::Base
belongs_to :person
belongs_to :role
belongs_to :practice
belongs_to :vehicle
attr_accessible :person_id, :role_id, :uebung_id, :vehicle_id
end