Forum: Ruby on Rails Split textarea content into array

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C95664a5c59ccdfb0da2f5910675c62c?d=identicon&s=25 Sudhi Kulkarni (sudhi)
on 2009-03-03 15:27
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
A91bd6cef23eb3516245a092e196c4da?d=identicon&s=25 Maurício Linhares (mauricio)
on 2009-03-03 15:30
(Received via mailing list)
You're probably calling the method at the wrong param. Show the form
you're using.

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



On Tue, Mar 3, 2009 at 11:27 AM, Sudhi Kulkarni
Aad37b5f7116c8d1f547d23b37566032?d=identicon&s=25 Greg Donald (destiney)
on 2009-03-04 04:04
(Received via mailing list)
On Tue, Mar 3, 2009 at 8:27 AM, Sudhi Kulkarni
<rails-mailing-list@andreas-s.net> 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 Donald
http://destiney.com/
This topic is locked and can not be replied to.