【发布时间】:2017-05-17 02:54:05
【问题描述】:
我需要将 API 端点添加到 Rails (5.0.2) 应用程序,因此我在 app/controllers/api 下创建了一个 TransitController。
控制器现在看起来像
module Api
class TransitController < ActionController::Api
def create
respond_to do |format|
format.json { render :status => :ok, :nothing => true }
end
end
end
end
我已将我的routes 更新如下
namespace :api do
post 'transits', to: 'transits#create'
end
但是现在,当我尝试通过 curl 到达端点时,我得到了
ActionController::RoutingError(未初始化的常量 ActionController::Api)
在 Rails 5+ 中,ActionController::Api 不应该默认可用吗?
我错过了什么吗?
谢谢
【问题讨论】:
标签: ruby-on-rails