我在运行时收到弃用警告rails test
。该警告如下。任何帮助都可以识别我做错了什么。
(编辑:旁注,渲染必须中断并从当前的控制器调用返回。我试图用ApplicationController.render(...)
它代替当前的render
调用,但它没有从控制器调用返回,并且我收到了错误/警告:no_content rendered
。)
警告:
DEPRECATION WARNING: Rendering actions with '.' in the name is deprecated: actions/action_success.json (called from update at /<path>/app/controllers/table_base_controller.rb:39)
render
抛出警告的代码就是在控制器中的这个调用:
render('/actions/action_success.json', locals: {
view: action.lookup_view('default'),
action: action,
area: current_area,
account: current_account
})
我尝试.json
按照指示取消(也尝试添加template: <path>
,尝试file: <path>
),但是,我在测试控制台中收到此错误:
Error:
TableControllerTest#test_Admin_should_update_via_loan_table:
ActionView::MissingTemplate: Missing template actions/action_success with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby, :jbuilder]}. Searched in:
* "/<path>/app/views"
app/controllers/table_base_controller.rb:39:in `update'
app/controllers/application_controller.rb:79:in `with_account'
test/controllers/table_controller_test.rb:14:in `block in <class:TableControllerTest>'
有问题的文件(路径:)app/views/actions/action_success.json.jbuilder
:
# frozen_string_literal: true
json.status 'success'
json.status_code 200
json.messages action.messages
if view
json.result do
json.partial! view.to_s, result: action.result, locals: { area: area }
end
else
json.result action.result
end