merit ruby​​ gem不使用条件语句

时间:2015-03-29 15:20:55

标签: ruby-on-rails ruby devise merit-gem

优点ruby gem不会在添加“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

1 个答案:

答案 0 :(得分:0)

您是否将实例变量添加到update重写操作? 请参阅维基页面:https://github.com/tute/merit/wiki/How-to-grant-badges-on-user-registration-using-Devise