无法在rails 3中手动创建设计用户

时间:2014-05-07 06:32:06

标签: ruby-on-rails devise

这个问题让我发疯了,我已经按照这里写的每个例子都没有发生任何事情。

我的代码如下:

@user = User.new(
          :username => params[:username],
          :email => params[:email],
          :password => params[:password],
          :password_confirmation => params[:password_confirmation],
          :birth_date => params[:birth_date],
          :gender => params[:gender]
        )
if object = @user.save
  output = "User created"
else
  output = "Error happened"
    ...

所以,我总是收到错误信息。

在服务器中我得到了这个输出:

Started POST "/moiapi/register.json" for 186.70.55.28 at 2014-05-07 02:25:10 -0400
Processing by MoiController#register as JSON
  Parameters: {"username"=>"demo1", "email"=>"demo1@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "birth_date"=>"1983-09-11", "gender"=>"M"}
   (0.2ms)  BEGIN
  User Exists (0.4ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'demo1@gmail.com' LIMIT 1
  User Exists (0.3ms)  SELECT 1 AS one FROM "users" WHERE LOWER("users"."username") = LOWER('demo1') LIMIT 1
   (0.1ms)  ROLLBACK
Completed 200 OK in 1069ms (Views: 0.1ms | ActiveRecord: 460.8ms)

作为最后的评论,用户不存在,我传递了password_confirmation参数,但.save方法返回false。

0 个答案:

没有答案