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:
leo.selig
2016-02-13 11:54:30 +01:00
parent f787445e5b
commit 773088798c
2 changed files with 8 additions and 4 deletions

View File

@ -109,8 +109,11 @@ class Exercise < ActiveRecord::Base
def from_proforma_xml(xml_string)
# how to extract the proforma functionality into a different module in rails?
xml = Nokogiri::XML(xml_string)
self.title = xml.xpath('/root/p:task/p:meta-data/p:title/text()')[0].content
self.description = xml.xpath('/root/p:task/p:description/text()')[0].content,
xml.collect_namespaces
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
end