Class: Api::MentorshipsController
- Inherits:
-
ApiController
- Object
- ApiController
- Api::MentorshipsController
- Defined in:
- app/controllers/api/mentorships_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)
-
- (Object) create
creates a new mentorship relationship paramters from JSON: name, pdSupervisor, pdInstitution, pdStartYear, pdEndYear currently assumes that all parameters are not nil not sure if we should render as json.
- - (Object) destroy
- - (Object) edit
- - (Object) index
- - (Object) new
- - (Object) show
- - (Object) update
Instance Method Details
- (Object) create
creates a new mentorship relationship paramters from JSON: name, pdSupervisor, pdInstitution, pdStartYear, pdEndYear currently assumes that all parameters are not nil not sure if we should render as json
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/controllers/api/mentorships_controller.rb', line 27 def create Rails.logger.info(params) if params.has_key?(:name) && params.has_key?(:pdSupervisor) && params.has_key?(:pdInstitution) && params.has_key?(:pdStartYear) && params.has_key(:pdEndYear) # need to find the person, supervisor, and institution IDs first name_id = Person.find_person_id(params[:name]) supervisor_id = Person.find_mentor_supervisor_id(params[:pdSupervisor], params[:pdInstitution]) instit_id = Institution.find_institution_id(params[:pdInstitution]) # check if the mentorship already exists unless Mentorship.exists?(:person_id => name_id, :mentor_id => supervisor_id, :institution_id => instit_id, :start => params[:pdStartYear], :end => params[:pdEndYear]) @mentorship = Mentorship.new_degree(params[:name], params[:pdSupervisor], params[:pdInstitution], params[:pdStartYear], params[:pdEndYear]) if @mentorship != nil && @mentorship.save render json: @mentorship.as_json, status: :created return end end end end |
- (Object) destroy
49 50 51 |
# File 'app/controllers/api/mentorships_controller.rb', line 49 def destroy render json: {warning: 'not implemented'}, status: 200 end |
- (Object) edit
19 20 21 |
# File 'app/controllers/api/mentorships_controller.rb', line 19 def edit render json: {warning: 'not implemented'}, status: 200 end |
- (Object) index
7 8 9 |
# File 'app/controllers/api/mentorships_controller.rb', line 7 def index render json: {warning: 'not implemented'}, status: 200 end |
- (Object) new
15 16 17 |
# File 'app/controllers/api/mentorships_controller.rb', line 15 def new render json: {warning: 'not implemented'}, status: 200 end |
- (Object) show
11 12 13 |
# File 'app/controllers/api/mentorships_controller.rb', line 11 def show render json: {warning: 'not implemented'}, status: 200 end |
- (Object) update
45 46 47 |
# File 'app/controllers/api/mentorships_controller.rb', line 45 def update render json: {warning: 'not implemented'}, status: 200 end |