0
我嵌套了我的資源(請參閱下文),當我嘗試創建新實體時,出現以下錯誤。有誰知道我爲什麼得到這個錯誤以及如何解決它?使用嵌套資源發佈
未定義的方法'應用爲無:NilClass
resources careers do
resources applications
end
在 '應用程序' 控制我有:
before_filter [[:authenticate, :except => :new], :load_career]
def create
# The following line is where the error originates
@application = @career.applications.new(params[:application])
respond_to do |format|
...
end
end
private
def load_career
@career = Career.find(params[:career_id])
end
的Career
和Application
車型分別有has_many :applications
和belongs_to :career
。
而'* _create_applications'遷移有一個career_id
字段。