Reputation: 868
I've read a couple of other posts for this error here, but no one really fits my problem.
The produced error is
ActiveRecord::UnknownAttributeError: unknown attribute: practice_id
It's happening while I try to build the uebung_maps in the rails console:
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'
my models and so on looks like following
Practice Model
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 Model
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
Upvotes: 0
Views: 1571
Reputation: 868
I've finally found the problem. The column in uebung_map wich should point to Pratice was named uebung_id in stead of practice_id.. now it's working
Upvotes: 0
Reputation: 10218
Try adding :practice_id
to your attr_accessible
, like so:
attr_accessible :person_id, :role_id, :uebung_id, :vehicle_id, :practice_id
Upvotes: 2