0

When sending a get request to http://localhost:3000/api/v1/events to test that my API works, I get the following error.

     Failure/Error: respond_with Event.all

     NoMethodError:
       undefined method `respond_with' for #<Api::V1::EventsController:0x007ff018f2edc8>
       Did you mean?  respond_to

My EventsController looks like this

class Api::V1::EventsController < ApplicationController
  respond_to? :json

  def index
    respond_with Event.all
  end

What am I doing wrong?

alpaca
  • 1,211
  • 13
  • 23

1 Answers1

0

remove the "?" in respond_to? :json

Tommy
  • 27
  • 6
  • That gives me `undefined method `respond_to' for Api::V1: :EventsController:Class (NoMethodError)` – alpaca Dec 18 '16 at 05:43
  • 1
    Are you using rails 5.0. In that case I think you need to add `include ActionController::MimeResponds` [see here](http://stackoverflow.com/a/35985101/7311465) – Tommy Dec 18 '16 at 05:48