【发布时间】:2017-05-03 12:05:57
【问题描述】:
向http://localhost:3000/api/v1/events 发送获取请求以测试我的 API 是否有效时,我收到以下错误。
Failure/Error: respond_with Event.all
NoMethodError:
undefined method `respond_with' for #<Api::V1::EventsController:0x007ff018f2edc8>
Did you mean? respond_to
我的 EventsController 看起来像这样
class Api::V1::EventsController < ApplicationController
respond_to? :json
def index
respond_with Event.all
end
我做错了什么?
【问题讨论】:
-
试试
render json: Event.all而不是respond_with
标签: ruby-on-rails rest api