reward.rb 443 Bytes
Newer Older
mafolz's avatar
mafolz committed
1
2
3
4
5
6
7
8
9
# encoding: UTF-8

## Definiert eine Belohnung, die eingelöst werden kann,
# z.B. 'Chipstüte' oder 'Bier'
class Reward < ActiveRecord::Base

  validates :points, :title, :presence => true

  validates :points, :numericality => {:greater_than => 0}
10
11
12
13
14
15
16
17
18

  def earn(hacker, user = nil)
    hacker.redemptions.create({
      :user   => user,
      :points => self.points,
      :chronicle_text => self.title,
      :reward => self
    })
  end
mafolz's avatar
mafolz committed
19
end