Note that there are some explanatory texts on larger screens.

plurals
  1. PORuby libxml parsing and inserting to database
    text
    copied!<p>I am currently trying to read from an xml file which records the jobs on a PBS. I have succesfullly managed to parse the code, but am unable to insert the objtects into my database, i receive this error:</p> <p>"You have a nil object when you didn't expect it! You might have expected an instance of ActiveRecord::Base. The error occurred while evaluating nil.delete"</p> <p>This is my Model:</p> <pre><code>require 'xml/libxml' class Job &lt; ActiveRecord::Base JOB_DIR = File.join('data', 'jobs') attr_reader :jobid, :user, :group, :jobname, :queue, :ctime attr_reader :qtime, :etime, :start, :owner def initialize(jobid, user, group, jobname, queue, ctime, qtime, etime, start, owner) @jobid, @user, @group, @jobname, @queue = jobid, user, group, jobname, queue @ctime, @qtime, @etime, @start, @owner = ctime, qtime, etime, start, owner end def self.find_all() jobs = [] input_file = "#{JOB_DIR}/1.xml" doc = XML::Document.file(input_file) doc.find('//execution_record').each do |node| jobs &lt;&lt; Job.new( node.find('jobid').to_a.first.content, node.find('user').to_a.first.content, node.find('group').to_a.first.content, node.find('jobname').to_a.first.content, node.find('queue').to_a.first.content, node.find('ctime').to_a.first.content, node.find('qtime').to_a.first.content, node.find('etime').to_a.first.content, node.find('start').to_a.first.content, node.find('owner').to_a.first.content ) end jobs end end </code></pre> <p>An my Model Controller:</p> <pre><code>class JobController &lt; ApplicationController def index @jobs = Job.find_all() end def create @jobs = Job.find_all() for job in @jobs job.save end end end </code></pre> <p>I would appreciate any help...Thank you!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload