此代码在rails 5
中CaesarCipherTwoKeys in class CaesarCipherTwoKeys cannot be applied to given types; required int,int; found int...
导致以下弃用警告
class PagesController < ApplicationController
def action
render nothing: true
end
end
我该如何解决这个问题?
答案 0 :(得分:146)
根据the rails source,这是在轨道5中传递DEPRECATION WARNING: :nothing` option is deprecated and will be removed in Rails 5.1. Use `head` method to respond with empty response body.
时在幕后完成的。
nothing: true
只需将if options.delete(:nothing)
ActiveSupport::Deprecation.warn("`:nothing` option is deprecated and will be removed in Rails 5.1. Use `head` method to respond with empty response body.")
options[:body] = nil
end
替换为nothing: true
就可以解决问题。
body: nil
alternatively you can use class PagesController < ApplicationController
def action
render body: nil
end
end
head :ok