0
的接受程度我有一个导航应用程序,它使离子(角度)应用程序消耗的API成为可能。在我的用户注册中,我要求用户在注册前同意服务条款,并在我的控制器中将其设置在我的参数中。rails json - 验证
在模型方面是这样的:
# agreeing to terms of service
validates_acceptance_of :terms_of_service, on: :create
控制器看起来是这样的:
def mobile_user_params
allowed = [:first_name, :last_name, :email, :password, :password_confirmation, :location, :terms_of_service]
params.require(:user).permit(allowed)
end
和最终结果在PARAMS是这样的:
{"user"=>{"terms_of_service"=>true}, "controller"=>"users", "action"=>"mobile_create", "format"=>"json"}
什么我的问题是,即使它是返回{"terms_of_service"=>true}
因为我接受它,这返回一个错误信息:
errors: {"Terms of Service must be accepted"}
有谁知道我怎么能满足这个验证?它使用复选框呈现HTML时有效,但在JSON请求上我似乎无法满足它。
任何帮助都将非常感激。