简体   繁体   中英

get :index, undefined method `respond_with' for Api::V1::EventsController

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?

remove the "?" in respond_to? :json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM