Sha256: eec6f4936191855fa196eb3b5105e75036aefdcd797920eae8cfc3c8abb7e303

Contents?: true

Size: 274 Bytes

Versions: 17

Compression:

Stored size: 274 Bytes

Contents

class Trophy < ActiveRecord::Base
  attr_accessible :generic_file_id, :user_id

  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

17 entries across 17 versions & 2 rubygems

Version Path
sufia-2.0.1 sufia-models/app/models/trophy.rb
sufia-models-2.0.1 app/models/trophy.rb
sufia-2.0.0 sufia-models/app/models/trophy.rb
sufia-models-2.0.0 app/models/trophy.rb
sufia-models-0.1.2 app/models/trophy.rb
sufia-models-0.1.1 app/models/trophy.rb
sufia-1.3.0 app/models/trophy.rb
sufia-models-0.1.0 app/models/trophy.rb
sufia-models-0.0.2 app/models/trophy.rb
sufia-models-0.0.1 app/models/trophy.rb
sufia-1.2.0 app/models/trophy.rb
sufia-1.1.0 app/models/trophy.rb
sufia-1.0.0 app/models/trophy.rb
sufia-0.1.0 app/models/trophy.rb
sufia-0.0.8 app/models/trophy.rb
sufia-0.0.7 app/models/trophy.rb
sufia-0.0.6 app/models/trophy.rb