简体   繁体   English

Merit + Rails 4和受保护的属性

[英]Merit + Rails 4 and protected attributes

Afternoon All, 下午全部,

I have just loaded merit gem, I've set up all my badges but on the action I see the following: 我刚刚加载了优点宝石,我已经设置了所有徽章,但在动作中我看到以下内容:

WARNING: Can't mass-assign protected attributes for Merit::Action:
user_id, action_method, action_value, had_errors, target_model,
target_id

I've tried putting the it in user attr_accessible but don't really want to give away the user_id like that. 我已经尝试将它放在用户attr_accessible中,但实际上并不想像这样放弃user_id。

Here is the point system: 这是点系统:

score 10, :to => :user, on: 'snippets#create' do |comment|
   comment.content.present?
end

Has anyone come across this issue. 有没有人遇到过这个问题。

I read the issues on github and has_merit in the model shouldn't cause this issue. 我在github上阅读了问题,模型中的has_merit不应该导致这个问题。

Here is the full log, if I'm readying this right it warns me and continues the insert anyway but my user has no points or badges. 这是完整的日志,如果我正在准备这个权利它警告我并继续插入,但我的用户没有积分或徽章。

   (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)

Little bit lost. 有点失落。

Problem was that merit wasn't yet prepared for the combination of Rails 4 and protected_attributes gem. 问题是尚未为Rails 4和protected_attributes gem的组合准备优点。 Fixed since today in master. 从今天开始修好了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM