Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > ask bout net-ping

Reply
Thread Tools

ask bout net-ping

 
 
Junior Junior wangsa
Guest
Posts: n/a
 
      04-02-2009
hi,

can anybody help me?
i wanna create a RoR monitoring application for my project.
i have a database with table named nodes
in that nodes i have id and ipadd.

here's my code:
#nodes_controller.rb

require 'net/ping'
include Net

class NodesController < ApplicationController
def index
@nodes = Node.find(:all)

@arr_stat = Array.new
i = 0
for node in @nodes do

stat = PingExternal.new(node.ipadd)

@arr_stat[i]['ipadd'] = node.ipadd
if stat
@arr_stat[i]['status'] = 'online';
puts "online"
else
@arr_stat[i]['status'] = 'offline';
puts "offline"
end
end

respond_to do |format|
format.html { render :html => @arr_stat }# index.html.erb
format.xml { render ml => @nodes }
end
end
##########################

why when i run the code it always says:

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.[]=

please help me solved this.
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
David Masover
Guest
Posts: n/a
 
      04-02-2009
On Wednesday 01 April 2009 20:40:12 Junior Junior wangsa wrote:

> @arr_stat[i]['ipadd'] = node.ipadd

[...]
> why when i run the code it always says:
>
> 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.[]=


I'm guessing @arr_stat[i] is nil at some point.

Also, for future reference, Rails raises that particular error quite often.
Pasting that would be like pasting "segmentation fault" to a C development
group. I'm sure the error included more information than that.

But you may want to take this to the Rails group.

 
Reply With Quote
 
 
 
 
Junior Junior wangsa
Guest
Posts: n/a
 
      04-02-2009
ups..
i post wrong place.. sorry
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Come and listen to my story 'bout a boy name Bush: Edward M Computer Support 3 09-05-2005 09:57 PM
Come and listen to my story 'bout a boy name Bush: Edward M Computer Support 0 09-04-2005 01:16 AM
another noob question bout controls Bruce ASP .Net 1 08-18-2005 08:56 PM
'bout time doS Computer Support 4 04-08-2005 07:46 PM
Any Folk Thinking Bout Buying Olympus Model C-4000 Digital Camera. david kelly Digital Photography 1 11-11-2003 07:19 PM



Advertisments