簡體   English   中英

優點紅寶石寶石不能與條件語句一起使用

[英]merit ruby gem not working with conditional statement

優點紅寶石寶石不會在添加了“ user.passion.present”的情況下向用戶添加積分。 沒有它就可以工作。 我通過使用Devise和Merit寶石來設置一切。 除此之外,一切似乎都有效。

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

您是否將實例變量添加到update覆蓋操作中? 請參閱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