3

我的应用程序控制器中有以下代码:

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。这似乎太简单了——帮助!

4

1 回答 1

8

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

于 2011-08-29T17:59:46.887 回答