Rails 5 控制器中未定义的方法 respond_to [英] undefined method respond_to in Rails 5 controller

查看:66
本文介绍了Rails 5 控制器中未定义的方法 respond_to的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序从 rails 3.something 升级到 rails 5.出于某种原因,每当我在我的任何控制器中使用该方法时,我都会收到未定义的方法 response_to.这以前有效,我希望这里有人可以提供帮助.

I'm upgrading an app from rails 3.something to rails 5. For some reason, I'm am getting undefindied method respond_to anytime I use that method in any of my controllers. This was working before and I was hoping someone here could help.

class StatusController < ApplicationController

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

推荐答案

根据 Rails5 个发行说明,

去掉respond_to/respond_with占位符方法,这个功能已提取到响应者宝石.

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

responders gem 添加到您的 Gemfile.

Add responders gem to your Gemfile.

这篇关于Rails 5 控制器中未定义的方法 respond_to的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆