# Ruby plugin getting 'undefined method'

**URL:** https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888
**Category:** Logstash
**Created:** [February 21, 2017, 1:36pm UTC](https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888 "2017-02-21T13:36:52Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)
#### Post date: [February 21, 2017, 1:36pm UTC](https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888/1 "2017-02-21T13:36:52Z")

</div>

Hi,  
I was wondering if anyone knew why I'm getting this exception for the following ruby code. It seems to not recognize the gsub method. Do I have to initialize it in order for LS to understand it?

```
ruby{
      code => {"
           a = event.get('Summary')
           a = a.gsub(/[^A-Za-z]/, '')
      "}
}

```

This is the error I'm getting:

```
[2017-02-21T08:27:53,959][ERROR][logstash.filters.ruby] Ruby exception occurred: undefined method `gsub' for #<Array:0x6f3945b6>
[2017-02-21T08:27:53,962][ERROR][logstash.filters.ruby] Ruby exception occurred: undefined method `gsub' for #<Array:0x4caf6a97>
```

---

<div class="post-metadata">

### Author: ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)
#### Post date: [February 21, 2017, 2:29pm UTC](https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888/2 "2017-02-21T14:29:39Z")

</div>

Your `Summary` field appears to contain an array and you can't use gsub on arrays.

---

<div class="post-metadata">

### Author: ![seanziee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seanziee/32/45151_2.png) [@seanziee](https://discuss.elastic.co/u/seanziee)
#### Post date: [February 21, 2017, 2:58pm UTC](https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888/3 "2017-02-21T14:58:21Z")

</div>

Wow, thanks. I didn't see that another input was coming in that had arrays in the summary. Been trying to figure out what has been happening for the past few hours. Thank you 🙂

---

<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 21, 2017, 2:58pm UTC](https://discuss.elastic.co/t/ruby-plugin-getting-undefined-method/75888/4 "2017-03-21T14:58:20Z")

</div>

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