以下のモデルを作成しました。
class Request < ActiveRecord::Base
end
class UrgentRequest < Request
has_one:note
end
class Note < ActiveRecord::Base
attr_accessible :request_id,....
belongs_to :urgent_request, :foreign_key=>'request_id', :class_name=>'Request'
end
私のコントローラでは、UrgentRequest
オブジェクトを作成するアクションを設定しました:
def new_scheduled_request
@request = UrgentRequest.new
@request.build_note #<-- getting error here
respond_to do |format|
format.html # new.html.erb
format.json { render json: @request }
end
end
次のエラーが表示されます。
ActiveRecord::UnknownAttributeError in RequestsController#new_urgent_request
unknown attribute: urgent_request_id
回線番号は、呼び出しを行っている場所ですbuild_note
。ページ上のフォームは、ネストされたフォームであると想定されています。ここで何が起こっていて、どうすれば修正できますか?