【问题标题】:The :status option on `head` has been deprecated on Rails 5`head` 上的 :status 选项在 Rails 5 上已被弃用
【发布时间】:2017-06-19 17:19:34
【问题描述】:

我收到以下错误

DEPRECATION WARNING: The :status option on `head` has been deprecated and will be removed in Rails 5.1. Please pass the status as a separate parameter before the options, instead.

在以下情况下使用:

def options
    head :status => 200, :'Access-Control-Allow-Headers' =>
    'accept, content-type, Authorization, cache-control, x-requested-with'
  end

该应用程序使用devise 进行身份验证,所以我怀疑这个代码是随之而来的。关于如何重写这个有什么建议吗?

【问题讨论】:

    标签: ruby-on-rails devise ruby-on-rails-5


    【解决方案1】:

    警告是“请在选项之前将状态作为单独的参数传递,而不是。”

    看起来像

    head 200

    或更多描述性

    head :ok

    查看这里以获得更详细的答案:The ":nothing" option is deprecated and will be removed in Rails 5.1

    【讨论】:

      猜你喜欢
      • 2015-08-10
      • 2016-06-25
      • 2023-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-10
      • 1970-01-01
      • 2022-08-08
      相关资源
      最近更新 更多