Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 4797

Undefined instance method "respond_to" in Rails 5 API Controller

$
0
0

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

NoMethodError (undefined method `respond_to' for #<Api::MyController:0x005645c81f0798>Did you mean?  respond_to?):

However, in the documentation for rails 4.2 it says http://edgeguides.rubyonrails.org/4_2_release_notes.html

respond_with and the corresponding class-level respond_to have been moved to the responders gem. Add gem 'responders', '~> 2.0' to your Gemfile to use it:

Instance-level respond_to is unaffected:

And I'm calling the instance method. What's the matter?

class ApplicationController < ActionController::APIend# ...class Api::MyController < ApplicationController  def method1    # ...    respond_to do |format|      format.xml { render(xml: "fdsfds") }      format.json { render(json: "fdsfdsfd" ) }    end

Viewing all articles
Browse latest Browse all 4797

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>