# Ruby exception occurred: undefined method \`include?' for nil:NilClass

**URL:** https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-include-for-nil-nilclass/119507
**Category:** Logstash
**Created:** [February 12, 2018, 3:59pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-include-for-nil-nilclass/119507 "2018-02-12T15:59:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![ssasporta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ssasporta/32/13695_2.png) [@ssasporta](https://discuss.elastic.co/u/ssasporta)
#### Post date: [February 12, 2018, 3:59pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-include-for-nil-nilclass/119507/1 "2018-02-12T15:59:47Z")

</div>

Hi,

What is wrong with my code? Why am I getting this error?

My Ruby code looks like that:

```
message_array = event.get("message").split("\n\n[", -1)
counter=0
message_array.each do | index | counter+=1
           if message_array[counter].include?("[1]")
              event.set("InterfaceName", message_array[counter])
          end
end

```

Thanks  
Sharon.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 12, 2018, 4:00pm UTC](https://discuss.elastic.co/t/ruby-exception-occurred-undefined-method-include-for-nil-nilclass/119507/2 "2018-03-12T16:00:07Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
