Fix array to string cast error
- accidental trailing comma caused this (apparently that's a thing in Ruby...) - cleaned up attribute assignments a little bit (persisted/validated/neither assignments) (leoselig/codeocean#1)
This commit is contained in:
@ -70,8 +70,9 @@ class ExercisesController < ApplicationController
|
|||||||
begin
|
begin
|
||||||
user = user_for_oauth2_request()
|
user = user_for_oauth2_request()
|
||||||
exercise = Exercise.new
|
exercise = Exercise.new
|
||||||
exercise.from_proforma_xml(request.body.read)
|
request_body = request.body.read
|
||||||
exercise.update(:user => user)
|
exercise.from_proforma_xml(request_body)
|
||||||
|
exercise.user = user
|
||||||
saved = exercise.save
|
saved = exercise.save
|
||||||
if saved
|
if saved
|
||||||
render :text => 'SUCCESS', :status => 200
|
render :text => 'SUCCESS', :status => 200
|
||||||
|
@ -109,8 +109,11 @@ class Exercise < ActiveRecord::Base
|
|||||||
def from_proforma_xml(xml_string)
|
def from_proforma_xml(xml_string)
|
||||||
# how to extract the proforma functionality into a different module in rails?
|
# how to extract the proforma functionality into a different module in rails?
|
||||||
xml = Nokogiri::XML(xml_string)
|
xml = Nokogiri::XML(xml_string)
|
||||||
self.title = xml.xpath('/root/p:task/p:meta-data/p:title/text()')[0].content
|
xml.collect_namespaces
|
||||||
self.description = xml.xpath('/root/p:task/p:description/text()')[0].content,
|
self.attributes = {
|
||||||
|
title: xml.xpath('/root/p:task/p:meta-data/p:title/text()')[0].content,
|
||||||
|
description: xml.xpath('/root/p:task/p:description/text()')[0].content
|
||||||
|
}
|
||||||
self.execution_environment_id = 1
|
self.execution_environment_id = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user