Sha256: 017e2ee1bea1723ced3cfa8bd4446903faf4b05a03a29ef33f5e74793ccd723e

Contents?: true

Size: 304 Bytes

Versions: 10

Compression:

Stored size: 304 Bytes

Contents

class Trophy < ActiveRecord::Base
  attr_accessible :generic_file_id, :user_id if Rails::VERSION::MAJOR == 3

  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

10 entries across 10 versions & 2 rubygems

Version Path
sufia-3.1.3 sufia-models/app/models/trophy.rb
sufia-models-3.1.3 app/models/trophy.rb
sufia-3.1.2 sufia-models/app/models/trophy.rb
sufia-models-3.1.2 app/models/trophy.rb
sufia-3.1.1 sufia-models/app/models/trophy.rb
sufia-models-3.1.1 app/models/trophy.rb
sufia-3.1.0 sufia-models/app/models/trophy.rb
sufia-models-3.1.0 app/models/trophy.rb
sufia-3.0.0 sufia-models/app/models/trophy.rb
sufia-models-3.0.0 app/models/trophy.rb