Ruby on Rails
Monday, July 6, 2015
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.
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/e934e5d2-bcd7-4390-b5f2-d073e4631f82%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment