I’m a super newbie with ruby on rails and ruby in general. Basically,
I’m
trying to display a pre-generated xml file within my rails app. Super
simple, but I can’t get it to work. I created a new controller called
“nmap” and it has this code:
class NmapController < ApplicationController
require ‘nmap/xml’
def create
@nmapfile = Nmapfile.new(nmapfile_params)
@nmapfile.nmapfilerecords = 0
@nmapfile.save
sleep 8
Nmap::XML.new(’/opt/ruby_projects/nmap/nmap_parse/app/views/nmap/test.nmap.xml’)
do |xml|
xml.each_host do |host|
if “#{host.status}” == “down”
else
@nmapfile.nmapfilerecords += 1
end
end
end
respond_to do |format|
if @nmapfile.save
format.html { redirect_to @nmapfile, notice: ‘nmap file was
successfully created.’ }
format.json { render action: ‘show’, status: :created, location:
@nmapfile }
else
format.html { render action: ‘new’ }
format.json { render json: @nmapfile.errors, status:
:unprocessable_entity }
end
end
end
I’ve placed my xml file in
“/opt/ruby_projects/nmap/nmap_parse/app/views/nmap/test.nmap.xml” as you
can see above. However, when I load the webapp, I receive the following
errors within the application trace:
/opt/ruby_projects/nmap/nmap_parse/app/controllers/nmap_controller.rb:30:
syntax error, unexpected $end, expecting keyword_end
This could be extremely simple to do, so I’m looking for someone to help
point me in the right direction.
tx.