# Ask bout net-ping

**URL:** <https://www.ruby-forum.com/t/ask-bout-net-ping/196927>\
**Category:** Ruby\
**Created:** [April 2, 2009, 3:40am UTC](https://www.ruby-forum.com/t/ask-bout-net-ping/196927 "2009-04-02T03:40:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vgenjr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9dc877/32.png) [@vgenjr](https://www.ruby-forum.com/u/vgenjr)\
**Post date:** [April 2, 2009, 3:40am UTC](https://www.ruby-forum.com/t/ask-bout-net-ping/196927/1 "2009-04-02T03:40:34Z")

</div>

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 :xml => @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.

---

<div class="post-metadata">

**Author:** ![vgenjr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9dc877/32.png) [@vgenjr](https://www.ruby-forum.com/u/vgenjr)\
**Post date:** [April 2, 2009, 5:31am UTC](https://www.ruby-forum.com/t/ask-bout-net-ping/196927/2 "2009-04-02T05:31:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vgenjr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9dc877/32.png) [@vgenjr](https://www.ruby-forum.com/u/vgenjr)\
**Post date:** [April 2, 2009, 6:26am UTC](https://www.ruby-forum.com/t/ask-bout-net-ping/196927/3 "2009-04-02T06:26:06Z")

</div>

ups…  
i post wrong place… sorry
