summaryrefslogtreecommitdiff
path: root/app/models/sim_card.rb
blob: 806beab39b86fd3c598fd53a73433aecdb177d0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class SimCard < ActiveRecord::Base
  attr_accessible :auto_order_card, :sip_account_id, :auth_key, :sim_number

  # Validations
  #
  validates :sim_card_provider_id,
            :presence => true

  belongs_to :sim_card_provider, :touch => true

  validates :sim_card_provider,
            :presence => true

  validates :sip_account_id,
            :presence => true            

  belongs_to :sip_account

  validates :sip_account,
            :presence => true            

  validates :sim_number,
            :presence => true

  after_initialize :set_defaults

  def to_s
    self.sim_number.to_s
  end

  private
  def set_defaults 
    self.state ||= 'not activated'
  end

end