我正在向我的 API 发送一个发布请求,它工作正常,它创建了一条新记录。但是,创建记录后,我在服务器日志中收到此错误
NoMethodError (undefined method `device_url' for #<Api::V1::DevicesController:0x007fa2f5dde5d8>):app/controllers/api/v1/devices_controller.rb:14:in `create'
这是我的创建动作
def create
respond_with Device.create(params[:device])
end
我所有的资源都在 Api#V1 下命名,这是我的路由文件
# Api ('/api')
namespace :api do
# Version 1 ('/api/v1')
namespace :v1 do
# Locations ('/api/v1/locations')
resources :locations
# Videos ('/api/v1/videos')
resources :videos
# Devices ('/api/v1/devices')
resources :devices
end
end