我做了以下模型:
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
呼叫的位置。页面上的表单应该是嵌套表单。这是怎么回事,我该如何解决?