class University

Schema Information

Table name: universities

id         :integer          not null, primary key
name       :string(255)
subdomain  :string(255)
active     :boolean          default(FALSE)
created_at :datetime
updated_at :datetime

Public Instance Methods

find_or_build_configurations() click to toggle source

It return the configuration array for the current university.

# File app/models/university.rb, line 33
def find_or_build_configurations
  Configuration.sub_configurations.each do |c|
    configurations.build(type: c.name) unless configurations.exists?(type: c.name)
  end
  configurations
end
reindex_elasticsearch() click to toggle source

Reindex elasticsearch.

# File app/models/university.rb, line 46
def reindex_elasticsearch
  ActsAsTenant.with_tenant(self) do
    [Student, Tutor, Course, Subject, Category].each do |model|
      puts "Deleting Index - #{model.index_name}"
      model.__elasticsearch__.delete_index!
      puts "finished Delete. now Creating index #{model.index_name}"
      model.__elasticsearch__.create_index!
      puts "updating index for #{model.index_name}"
      index = 0
      model.find_each do |object|
        begin
          object.__elasticsearch__.index_document
          print "\r#{index+=1} records updated"
        rescue => e
          puts "unable to update index for #{object.id} - #{e}"
        end
      end
      puts "\n"
    end
  end
end
to_param() click to toggle source

Returns subdomain for university.

# File app/models/university.rb, line 28
def to_param
  subdomain
end
url() click to toggle source

Returns url for university site.

# File app/models/university.rb, line 41
def url
  "#{subdomain}.#{ActionMailer::Base.default_url_options[:host]}"
end