Sha256: 55be94997909a54672b592c0c6c66573408697cf8c8b15b16b47d01d2fba838d

Contents?: true

Size: 225 Bytes

Versions: 37

Compression:

Stored size: 225 Bytes

Contents

class Trophy < ActiveRecord::Base
  validate :count_within_limit, on: :create

  def count_within_limit
    if Trophy.where(user_id:self.user_id).count >= 5
      errors.add(:base, "Exceeded trophy limit")
    end
  end
end

Version data entries

37 entries across 37 versions & 2 rubygems

Version Path
sufia-models-6.2.0 app/models/trophy.rb
sufia-models-6.1.0 app/models/trophy.rb
sufia-5.0.0 sufia-models/app/models/trophy.rb
sufia-models-5.0.0 app/models/trophy.rb
sufia-models-6.0.0 app/models/trophy.rb
sufia-6.0.0 sufia-models/app/models/trophy.rb
sufia-6.0.0.rc4 sufia-models/app/models/trophy.rb
sufia-models-6.0.0.rc4 app/models/trophy.rb
sufia-6.0.0.rc3 sufia-models/app/models/trophy.rb
sufia-models-6.0.0.rc3 app/models/trophy.rb
sufia-5.0.0.rc1 sufia-models/app/models/trophy.rb
sufia-models-5.0.0.rc1 app/models/trophy.rb
sufia-6.0.0.rc2 sufia-models/app/models/trophy.rb
sufia-models-6.0.0.rc2 app/models/trophy.rb
sufia-6.0.0.rc1 sufia-models/app/models/trophy.rb
sufia-models-6.0.0.rc1 app/models/trophy.rb
sufia-4.3.1 sufia-models/app/models/trophy.rb
sufia-models-4.3.1 app/models/trophy.rb
sufia-6.0.0.beta1 sufia-models/app/models/trophy.rb
sufia-models-6.0.0.beta1 app/models/trophy.rb