验证失败:电子邮件无效,密码不能为空(ActiveRecord :: RecordInvalid)

时间:2013-12-27 20:55:22

标签: ruby-on-rails validation rake

我决定在这个github repo的提交之后进行一次练习,并且在一次失败的验证中陷入困境。当我运行'rake'时,我得到以下回复:

Scenario: Admin signs in            # features/admin.feature:2
  Given the following admin:        # features/step_definitions/fabrication_steps.rb:19
    | email    | dl@example.com |
    | password | password       |
    Validation failed: Email is invalid, Password can't be blank (ActiveRecord::RecordInvalid)
    ./features/step_definitions/fabrication_steps.rb:21:in `block (2 levels) in <top (required)>'
    ./features/step_definitions/fabrication_steps.rb:6:in `with_ivars'
    ./features/step_definitions/fabrication_steps.rb:20:in `/^the following ([^"]*):$/'
    features/admin.feature:3:in `Given the following admin:'

我克隆了作者的回购,恢复了我目前被卡住的提交,并注意到'rake'首先产生了以下输出(我没有发生):

NOTICE: CREATE TABLE will create implicit sequence "admins_id_seq" for serial column "admins.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "admins_pkey" for table "admins"
NOTICE: CREATE TABLE will create implicit sequence "posts_id_seq" for serial column "posts.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "posts_pkey" for table "posts"
/home/dl/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S bundle exec cucumber --profile default
Using the default profile...

我尝试了以下命令,也无济于事:

rake db:create
rake db:setup
rake db:test:prepare
rake

其他潜在的解决方案似乎也不合适。我错过了什么?

1 个答案:

答案 0 :(得分:0)

原来这是模型中的一个问题,它反映了rails 3(原始repo)和rails 4(me)之间的区别。

我对管理模型和控制器进行了一些更改,以处理批量分配。

如果有人遇到此消息并想了解更多信息,请告诉我。