Rails设计注册表单不接受自定义用户名字段

我正在尝试为我的设计安装添加一个用户名,一个Railscast插曲。 我已将该字段添加到我的用户模型中,但是当我尝试使用用户名创建新用户时,表单操作会一直尝试将空值传递给我的数据库,这会引发错误。

这是我的用户模型的架构:

create_table "users", :force => true do |t| t.string "username", :null => false t.string "email", :default => "", :null => false t.string "encrypted_password", :limit => 128, :default => "", :null => false t.string "password_salt", :default => "", :null => false t.string "reset_password_token" t.string "remember_token" t.datetime "remember_created_at" t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" t.datetime "created_at" t.datetime "updated_at" end 

这是通过我的注册表单传递的哈希:

 {"utf8"=>"✓", "authenticity_token"=>"/6Mf3mAd4TQ8uqJ4nPZAu/HbPnktKFmJ+G76j2pUV7U=", "user"=>{"email"=>"email@email.co", "username"=>"test", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"} 

但是,如上所述,这会引发错误。 特别是因为它试图在表中插入NULL,即使POST哈希包含username的值。

任何帮助表示赞赏。

您确定用户名在您的attr_accessible列表中吗?