加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby – 在Rails 5控制器中的undefined方法respond_to

发布时间:2020-12-17 04:31:48 所属栏目:百科 来源:网络整理
导读:我正在将一个应用程序从rails 3.something升级到rails 5.出于某种原因,我在任何时候在任何控制器中使用该方法时都会得到未经证实的方法respond_to.这是以前工作,我希望有人在这里可以提供帮助. class StatusController ApplicationController #this throws a
我正在将一个应用程序从rails 3.something升级到rails 5.出于某种原因,我在任何时候在任何控制器中使用该方法时都会得到未经证实的方法respond_to.这是以前工作,我希望有人在这里可以提供帮助.
class StatusController < ApplicationController

  #this throws an error 'undefined method respond_to
  respond_to :json,:html     
 end

解决方法

按照 Rails 5 release notes,

Remove respond_to/respond_with placeholder methods,this functionality
has been extracted to the responders gem.

将响应者gem添加到您的Gemfile中.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读