我已经安装了 Devise 和 CanCan,它们似乎都在工作。我在迁移中有“角色”列,但是当我在添加用户后检查日志时,BD 查询显示没有添加角色的迹象
完整的东西看起来像这样:
Processing by Devise::RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"S+SjhxsALMbHkRBPPwOMIvHo1Bd0cNYl1g=", "user"=>{"email"=>"david@mail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "role"=>"receptionist"}, "commit"=>"Sign up"}
Unpermitted parameters: role
(0.2ms) begin transaction
User Exists (0.2ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'david@mail.com' LIMIT 1
Binary data inserted for `string` type on column `encrypted_password`
SQL (3.1ms) INSERT INTO "users" ("created_at", "email", "encrypted_password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Thu, 24 Oct 2013 08:52:31 UTC +00:00], ["email", "david@mail.com"], ["encrypted_password", "$2a$10$e3hKTibsZ7qSgOC5OelKgjumU8ufu46xNrBkmXcDEpix/m"], ["updated_at", Thu, 24 Oct 2013 08:52:31 UTC +00:00]]
(0.7ms) commit transaction
(0.1ms) begin transaction
Binary data inserted for `string` type on column `last_sign_in_ip`
Binary data inserted for `string` type on column `current_sign_in_ip`
SQL (0.7ms) UPDATE "users" SET "last_sign_in_at" = ?, "current_sign_in_at" = ?, "last_sign_in_ip" = ?, "current_sign_in_ip" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = 2 [["last_sign_in_at", Thu, 24 Oct 2013 08:52:31 UTC +00:00], ["current_sign_in_at", Thu, 24 Oct 2013 08:52:31 UTC +00:00], ["last_sign_in_ip", "127.0.0.1"], ["current_sign_in_ip", "127.0.0.1"], ["sign_in_count", 1], ["updated_at", Thu, 24 Oct 2013 08:52:31 UTC +00:00]]
(0.6ms) commit transaction
Redirected to http://0.0.0.0:3000/
Completed 302 Found in 108ms (ActiveRecord: 5.6ms)
此外,如果我编辑用户并添加角色,我会在日志中收到以下错误
不允许的参数:角色
我觉得迁移可能不起作用..但我可以访问角色变量..所以我不完全理解。
我对rails相当陌生,所以我期待(并希望)我省略了一些明显的东西。
提前致谢