Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 设计登记表问题_Ruby On Rails_Devise_Customization_Registration - Fatal编程技术网

Ruby on rails 设计登记表问题

Ruby on rails 设计登记表问题,ruby-on-rails,devise,customization,registration,Ruby On Rails,Devise,Customization,Registration,我正在通过项目上的React Rails使用Rails 4、Desive for auth和React.JS来查看视图 目前我正在尝试让自定义注册工作。我一步一步地遵循文档,为我的用户/注册\控制器定制了我的路由,并使一切都能正常工作 我正在使用jquery从前端的表单中启动ajax。目前,我们已经为测试硬编码了一些数据 我现在收到422回复,说在我发送时找不到密码和电子邮件。但是,它没有提到任何关于传入的其他值的内容,所以看起来它仍然会被默认的Desive引擎。。。任何帮助都会很好,我知道De

我正在通过项目上的React Rails使用Rails 4、Desive for auth和React.JS来查看视图

目前我正在尝试让自定义注册工作。我一步一步地遵循文档,为我的用户/注册\控制器定制了我的路由,并使一切都能正常工作

我正在使用jquery从前端的表单中启动ajax。目前,我们已经为测试硬编码了一些数据

我现在收到422回复,说在我发送时找不到密码和电子邮件。但是,它没有提到任何关于传入的其他值的内容,所以看起来它仍然会被默认的Desive引擎。。。任何帮助都会很好,我知道Desive以难以配置而闻名

这是我的控制器功能-

def create
     @user= User.new(configure_sign_up_params)
respond_to do |format| 
  if @user.save
      format.html { redirect_to @user, notice: 'User was successfully created.' }
      format.json { render :show, status: :created, location: @user }
  else
      format.html { render :new }
      format.json { render json: @user.errors, status: :unprocessable_entity }
  end
end
这是我的强参数函数-

 def configure_sign_up_params
   devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:email, :password, :password_confirmation) } 
 end
这是我在JSOn.stringify'ing之后发送的数据-

 let formData =
        {
            "username": "test", // document.getElementById('username').value
            "password": "1234",
            "password_confirmation": "1234",
            "email": "test@gmail.com",
            "membership": "community"
        }
这是我的网络响应中的错误-422与此机构-

{"email":["can't be blank"],"password":["can't be blank"]}
提前谢谢

尝试将其作为

{
  user: {
    "username": "test",
    "password": "1234",
    "password_confirmation": "1234",
    "email": "test@gmail.com",
    "membership": "community"
  }
}
由于Deviate执行类似于
参数(:user)
的操作,它返回
nil
,因为参数中没有用户键

请尝试将其作为

{
  user: {
    "username": "test",
    "password": "1234",
    "password_confirmation": "1234",
    "email": "test@gmail.com",
    "membership": "community"
  }
}
因为designe执行类似于
params(:user)
的操作,它返回
nil
,因为参数中没有用户键