Class: Api::DegreesController

Inherits:
ApiController
  • Object
show all
Defined in:
app/controllers/api/degrees_controller.rb

Overview

temporarily filled out but not used yet (just AggregatedController used) will have to figure out how to pass the json parameters to this controller

Instance Method Summary (collapse)

Instance Method Details

- (Object) create

this will be called to create a new degree parameters from JSON: year, type, institution will likely need to be called each time a degree needs to be made? *** Will deal with handling the array in this controller later currently assumes that all parameters are not nil not sure if we should render as json



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'app/controllers/api/degrees_controller.rb', line 29

def create
  Rails.logger.info(params)
  if params.has_key?(:year) && params.has_key?(:type) && params.has_key?(:institution)
    # need to find the institution id first
    instit_id = Institution.find_institution_id(params[:institution])
    # check if the degree exists first
    unless Degree.exists?(year: params[:year], degree_type: params[:type], :institution_id => instit_id)
      @degree = Degree.new_degree(params[:year], params[:type], params[:institution])
      if @degree != nil && @degree.save
        render json: @degree.as_json, status: :created
        return
      end
    end
  end
end

- (Object) destroy



49
50
51
# File 'app/controllers/api/degrees_controller.rb', line 49

def destroy
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) edit



19
20
21
# File 'app/controllers/api/degrees_controller.rb', line 19

def edit
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) index



7
8
9
# File 'app/controllers/api/degrees_controller.rb', line 7

def index
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) new



15
16
17
# File 'app/controllers/api/degrees_controller.rb', line 15

def new
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) show



11
12
13
# File 'app/controllers/api/degrees_controller.rb', line 11

def show
  render json: {warning: 'not implemented'}, status: 200
end

- (Object) update



45
46
47
# File 'app/controllers/api/degrees_controller.rb', line 45

def update
  render json: {warning: 'not implemented'}, status: 200
end