gpt4 book ai didi

ruby-on-rails - Rails 未定义常量:ActiveRecord::RecordNotFound

转载 作者:行者123 更新时间:2023-12-03 22:39:32 26 4
gpt4 key购买 nike

我的应用程序 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

当我运行它时(实际上是运行 rake db:migrate),我收到错误 uninitialized constant ActiveRecord::RecordNotFound。这似乎太简单了——帮助!

最佳答案

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

关于ruby-on-rails - Rails 未定义常量:ActiveRecord::RecordNotFound,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7226593/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com