Class: Institution

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/institution.rb

Overview

Model for handling institutions

Class Method Summary (collapse)

Instance Method Summary (collapse)

Class Method Details

+ (Hash{String => String, Number}) new_institution(name)

Creates a new institution

Parameters:

  • name (String)

    name of the institution

Returns:

  • (Hash{String => String, Number})

    created institution



10
11
12
13
14
15
16
# File 'app/models/institution.rb', line 10

def Institution.new_institution(name)
  name = name.downcase

  institution = Institution.create_with(approved: false)
                            .find_or_create_by(name: name)
  return institution
end

Instance Method Details

- (Object) as_json(options = {})

Handles rendering an institution in a JSON format.



19
20
21
# File 'app/models/institution.rb', line 19

def as_json(options={})
  super(:except => [:created_at, :updated_at, :approved])
end