Sha256: c5b3eb0f61e7813f9ef20034a830a86ce0bdaee15a8c64d143678a48567852cb

Contents?: true

Size: 631 Bytes

Versions: 8

Compression:

Stored size: 631 Bytes

Contents

module Scidea
  module Schools
    module Models
      module Profile
        extend ActiveSupport::Concern

        included do
          belongs_to :school
          validate :school_present_if_educator_audience
        end

        module InstanceMethods
          def audience_is_educator?
            audience && audience.name.downcase == 'educator'
          end

          def school_present_if_educator_audience
            errors.add(:school, "Educational institution required if you are an educator") if audience_is_educator? && school.nil?
          end
        end      

      end # profile
    end # models
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scidea-schools-1.1 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.6 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.5 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.4 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.3 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.2 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.1 lib/scidea/schools/models/profile.rb
scidea-schools-1.0.0 lib/scidea/schools/models/profile.rb