我在这个上花了太长时间,所以我想我会在这里分享,希望能为别人节省一点时间。
上面的错误来自调用时正在执行的require()方法ActiveSupport::Dependencies::Loadable
params.require(:user)...
strong_parameters注入ActionController::StrongParameters到这个文件的ActionController::Base底部
ActionController::Base.send :include, ActionController::StrongParameters
rails-apigem 需要您的应用程序的扩展ApplicationController以ActionController::API支持ActionController::Base
应用程序控制器对此一无所知,ActionController::StrongParameters因为它们没有扩展ActionController::StrongParameters包含在其中的类。这就是为什么require()方法调用没有调用ActionController::StrongParameters.
讲述就像将以下内容添加ActionController::API到.ActionController::StrongParametersconfig/initializers
ActionController::API.send :include, ActionController::StrongParameters