0

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

2
  • There is a typo, @p = Practive.newshould be @p = Practice.new Commented Mar 30, 2013 at 20:34
  • I've done that right.. edit is also done :) Commented Mar 30, 2013 at 21:05

2 Answers 2

2

Try adding :practice_id to your attr_accessible, like so:

attr_accessible :person_id, :role_id, :uebung_id, :vehicle_id, :practice_id
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.