# Split textarea content into array

**URL:** <https://www.ruby-forum.com/t/split-textarea-content-into-array/161897>\
**Category:** Rails\
**Created:** [March 3, 2009, 3:27pm UTC](https://www.ruby-forum.com/t/split-textarea-content-into-array/161897 "2009-03-03T15:27:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [March 3, 2009, 3:27pm UTC](https://www.ruby-forum.com/t/split-textarea-content-into-array/161897/1 "2009-03-03T15:27:27Z")

</div>

Hi,

I am a newbie to rails and have a problem to solve. I have textarea  
which provides as input

Line1  
Line2  
Line3

I want this content to be split into an array using “\r\n” as the  
seperators.  
I tried to do the split directly on params[:content].split("\r\n") but  
got an error which says called a private method of HASH.

I convert params[:content].to\_s then I guess my \r\n’s are lost.

How do I get this split working?

Regards,  
Sudhi

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [March 3, 2009, 3:30pm UTC](https://www.ruby-forum.com/t/split-textarea-content-into-array/161897/2 "2009-03-03T15:30:02Z")

</div>

You’re probably calling the method at the wrong param. Show the form  
you’re using.

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

On Tue, Mar 3, 2009 at 11:27 AM, Sudhi K.

---

<div class="post-metadata">

**Author:** ![sudhi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dbc845/32.png) [@sudhi](https://www.ruby-forum.com/u/sudhi)\
**Post date:** [March 4, 2009, 4:04am UTC](https://www.ruby-forum.com/t/split-textarea-content-into-array/161897/3 "2009-03-04T04:04:44Z")

</div>

On Tue, Mar 3, 2009 at 8:27 AM, Sudhi K.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I tried to do the split directly on params[:content].split(“\r\n”) but  
> got an error which says called a private method of HASH.
> 
> I convert params[:content].to\_s then I guess my \r\n’s are lost.
> 
> How do I get this split working?

params[:content].split(“\r\n”) works for me. Post more code.

–  
Greg D.  
[http://destiney.com/](http://destiney.com/)
