0
我做了以下型號:的ActiveRecord :: UnknownAttributeError Rails中使用STI車型時
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
電話。頁面上的表單應該是嵌套表單。這裏發生了什麼,我該如何解決它?