gpt4 book ai didi

ruby-on-rails - Merit + Rails 4 和 protected 属性

转载 作者:行者123 更新时间:2023-12-02 04:57:25 27 4
gpt4 key购买 nike

下午好

我刚刚加载了 merit gem,我已经设置了所有徽章,但在操作时我看到以下内容:

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)

有点迷失。

最佳答案

问题是,尚未为 Rails 4 和 protected_attributes gem 的组合做好准备。从今天开始在 master 中修复。

关于ruby-on-rails - Merit + Rails 4 和 protected 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20150189/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com