下午所有,
我刚刚加载了功绩宝石,我已经设置了所有徽章,但在操作中我看到以下内容:
WARNING: Can't mass-assign protected attributes for Merit::Action:
user_id, action_method, action_value, had_errors, target_model,
target_id
我已经尝试将它放在用户 attr_accessible 中,但真的不想像那样放弃 user_id。
这是积分系统:
score 10, :to => :user, on: 'snippets#create' do |comment|
comment.content.present?
end
有没有人遇到过这个问题。
我在 github 上阅读了问题,模型中的 has_merit 不应该导致这个问题。
这是完整的日志,如果我准备好了,它会警告我并继续插入,但我的用户没有积分或徽章。
(2.5ms) COMMIT
(0.1ms) BEGIN
SQL (3.3ms) UPDATE "snippets" SET "user_id" = $1, "updated_at" = $2 WHERE "snippets"."id" = 11 [["user_id", 1], ["updated_at", Fri, 22 Nov 2013 16:55:02 UTC +00:00]]
Merit::Sash Load (0.3ms) SELECT "sashes".* FROM "sashes" WHERE "sashes"."id" = $1 ORDER BY "sashes"."id" ASC LIMIT 1 [["id", 3]]
Merit::Score Load (1.5ms) SELECT "merit_scores".* FROM "merit_scores" WHERE "merit_scores"."sash_id" = $1 AND "merit_scores"."category" = 'default' ORDER BY "merit_scores"."id" ASC LIMIT 1 [["sash_id", 3]]
(1.7ms) SELECT SUM("merit_score_points"."num_points") AS sum_num_points, score_id AS score_id FROM "merit_score_points" WHERE "merit_score_points"."score_id" = $1 GROUP BY score_id [["score_id", 3]]
(3.5ms) COMMIT
Redirected to http://0.0.0.0:3000/books/1
WARNING: Can't mass-assign protected attributes for Merit::Action: user_id, action_method, action_value, had_errors, target_model, target_id
(0.4ms) BEGIN
SQL (0.5ms) INSERT INTO "merit_actions" ("created_at", "updated_at") VALUES ($1, $2) RETURNING "id" [["created_at", Fri, 22 Nov 2013 16:55:02 UTC +00:00], ["updated_at", Fri, 22 Nov 2013 16:55:02 UTC +00:00]]
(1.4ms) COMMIT
Merit::Action Load (0.5ms) SELECT "merit_actions".* FROM "merit_actions" WHERE "merit_actions"."processed" = 'f'
(0.2ms) BEGIN
SQL (4.6ms) UPDATE "merit_actions" SET "processed" = $1, "updated_at" = $2 WHERE "merit_actions"."id" = 13 [["processed", true], ["updated_at", Fri, 22 Nov 2013 16:55:02 UTC +00:00]]
(1.4ms) COMMIT
Completed 302 Found in 226ms (ActiveRecord: 43.0ms)
有点失落。