简体   繁体   中英

Rails Undefined Constant: ActiveRecord::RecordNotFound

I have the following code in my Application Controller:

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

When I run it (actually I run rake db:migrate ) I get the error uninitialized constant ActiveRecord::RecordNotFound . This seems too simple -- HELP!

它需要require 'active_record/errors' ,我在require 'active_record/errors'搜索时发现的所有示例中都没有看到。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM