简体   繁体   English

优点红宝石宝石不能与条件语句一起使用

[英]merit ruby gem not working with conditional statement

The merit ruby gem is not adding the points to the user with the "user.passion.present" added. 优点红宝石宝石不会在添加了“ user.passion.present”的情况下向用户添加积分。 It works without it. 没有它就可以工作。 I set everything up with working with Devise and Merit gems. 我通过使用Devise和Merit宝石来设置一切。 Everything seems to work except this. 除此之外,一切似乎都有效。

module Merit
  class PointRules
    include Merit::PointRulesMethods

    def initialize
      score 50, :on => 'user/registrations#create', model_name: 'User'


        score 10, :on => 'user/registrations#update', model_name: 'User' do |user|
         user.passion.present?
       end




      #
      # score 15, :on => 'reviews#create', :to => [:reviewer, :reviewed]
      #
      # score 20, :on => [
      #   'comments#create',
      #   'photos#create'
      # ]

      score 20, on: 'lyrics#create', to: :user, description: 'Plus 20 points'

      score (-20), on: 'lyrics#destroy', to: :user
    end
  end
end

Did you add the instance variable to the update overridden action? 您是否将实例变量添加到update覆盖操作中? See wiki page: https://github.com/tute/merit/wiki/How-to-grant-badges-on-user-registration-using-Devise . 请参阅Wiki页面: https : //github.com/tute/merit/wiki/How-to-grant-badges-on-user-registration-using-Devise

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

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