最近我将我的应用程序从Ruby版本2.6.1更新到3.0.1,我使用rbenv作为版本管理器。
但是当我尝试运行rails服务器时,
=> Booting Puma
=> Rails 6.1.3 application starting in development
=> Run `bin/rails server --help` for more startup options
Exiting
/home/humayun/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/activesupport-6.1.3/lib/active_support/rescuable.rb:56:in `rescue_from': Need a handler. Pass the with: keyword argument or provide a block. (ArgumentError)
from /home/humayun/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/will_paginate-3.1.8/lib/will_paginate/railtie.rb:67:in `rescue_from'
from /home/humayun/umerfarooq/Alchemy/app/controllers/application_controller.rb:2:in `<class:ApplicationController>'
from /home/humayun/umerfarooq/Alchemy/app/controllers/application_controller.rb:1:in `<main>'
我刚刚读了Here关于导致第56行错误的函数。
applciation_controller.rb
rescue_from Exception, with: :handle_exception
protect_from_forgery prepend: true, with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :initialize_api
def not_found
raise ActionController::RoutingError.new('Not Found')
end
def handle_exception(exception = nil)
return render_404 if [ActionController::RoutingError, ActiveRecord::RecordNotFound].include?(exception.class)
render_500
end
我认为这是因为贬值。
有谁能告诉我如何处理这些错误吗?
2条答案
按热度按时间5m1hhzi41#
您的
handle_exception
可能需要一个块来呈现视图或返回状态正如在
app/controllers/application_controller.rb:2
中的错误中提到的,您可能有一个没有错误或处理程序的rescue_from
,您需要遵循以下任何语法根据此处的文档https://apidock.com/rails/ActiveSupport/Rescuable/ClassMethods/rescue_from
-更新:
这是由于您正在使用的
will_paginate
gem覆盖了控制器中的rescue_from
方法,以及新的ruby更新更改了关键字属性的行为如果你的基本控制器
include ControllerRescuePatch
你可能可以删除它,这将修复它,但不确定会发生什么事,你的分页。否则,推迟ruby更新,直到will_paginate
更新他们的代码来修复这个问题。628mspwn2#
我只是试着使用will_paginategem的最新版本,它对我很有效。