Undefined instance method “respond_to” in Rails 5 API Controller

前端 未结 2 1786
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-13 05:51

In rails 5 created with --api I have an error

NoMethodError (undefined method `respond_to\' for #
Did         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-13 06:27

    As of Rails 4.2, this functionality no longer ships with Rails, but can easily be included with the responders gem (like Max noted in comments above).

    Add gem 'responders' to your Gemfile, then

    $ bundle install
    $ rails g responders:install
    

    Sources:
    http://edgeguides.rubyonrails.org/4_2_release_notes.html#respond-with-class-level-respond-to https://github.com/plataformatec/responders

提交回复
热议问题