[英]Rails Undefined Constant: ActiveRecord::RecordNotFound
我的應用程序控制器中有以下代碼:
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
private
def record_not_found
render :text => "404 Not Found", :status => 404
end
end
當我運行它(實際上我運行rake db:migrate
)時,出現錯誤uninitialized constant ActiveRecord::RecordNotFound
。 這似乎太簡單了-幫助!
它需要require 'active_record/errors'
,我在require 'active_record/errors'
搜索時發現的所有示例中都沒有看到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.