Sha256: a3519a3442f8fffd68812f7126ccce5b79caa61e144e69863ff2114d89d0f972

Contents?: true

Size: 411 Bytes

Versions: 16

Compression:

Stored size: 411 Bytes

Contents

module Gaku
  class EnrollmentStatus < ActiveRecord::Base
    has_many :students, foreign_key: :enrollment_status_code, primary_key: :code

    translates :name

    validates :code, presence: true, uniqueness: true

    before_create :set_name

    scope :active,  -> { where(active: true) }

    def to_s
      name
    end

    private

    def set_name
      self.name = code if name.nil?
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_core-0.3.0 app/models/gaku/enrollment_status.rb
gaku_core-0.3.0.pre.4 app/models/gaku/enrollment_status.rb
gaku_core-0.3.0.pre.3 app/models/gaku/enrollment_status.rb
gaku_core-0.3.0.pre.2 app/models/gaku/enrollment_status.rb
gaku_core-0.3.0.pre.1 app/models/gaku/enrollment_status.rb
gaku_core-0.3.0.pre.0 app/models/gaku/enrollment_status.rb
gaku-0.2.4 core/app/models/gaku/enrollment_status.rb
gaku_core-0.2.4 app/models/gaku/enrollment_status.rb
gaku-0.2.3 core/app/models/gaku/enrollment_status.rb
gaku_core-0.2.3 app/models/gaku/enrollment_status.rb
gaku-0.2.2 core/app/models/gaku/enrollment_status.rb
gaku_core-0.2.2 app/models/gaku/enrollment_status.rb
gaku-0.2.1 core/app/models/gaku/enrollment_status.rb
gaku_core-0.2.1 app/models/gaku/enrollment_status.rb
gaku-0.2.0 core/app/models/gaku/enrollment_status.rb
gaku_core-0.2.0 app/models/gaku/enrollment_status.rb