Forum: Ruby on Rails Textarea and line breaks

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.
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 13:08
(Received via mailing list)
Hi everyone!
                     Guys I am facing very irritating problem of line
breaks
in text area, i used "gsub" method to replace \r\n to <br/>, but i
didn't
got the result as was i expecting.
                     Could anybody give me any suggestions to resolve
this
issue?

Thanks,
Shahroon
00973881979aa0a660ffbbb2f7a907fb?d=identicon&s=25 Peter De Berdt (Guest)
on 2009-02-23 13:11
(Received via mailing list)
On 23 Feb 2009, at 13:07, shahroon ali wrote:

>                      Guys I am facing very irritating problem of
> line breaks in text area, i used "gsub" method to replace \r\n to
> <br/>, but i didn't got the result as was i expecting.
>                      Could anybody give me any suggestions to
> resolve this issue?

<%= simple_format(@record.field_name) %>


Best regards

Peter De Berdt
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 13:17
(Received via mailing list)
simple_format gave me this

<p>James, <br />Andy, <br />Candy</p>

but i want line breaks like this

James
Andy
Candy

I hope now you can understand what my problem is.

Thanks,
Shahroon

On Mon, Feb 23, 2009 at 5:10 PM, Peter De Berdt
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 13:39
(Received via mailing list)
Sending again :)

simple_format gave me this

<p>James, <br />Andy, <br />Candy</p>

but i want line breaks like this

James
Andy
Candy

I hope now you can understand what my problem is.

Thanks,
Shahroon

On Mon, Feb 23, 2009 at 5:10 PM, Peter De Berdt
80e4cb97cae5c8d745f72337d93fd8f2?d=identicon&s=25 MaD (Guest)
on 2009-02-23 14:11
(Received via mailing list)
> Sending again :)
why? was 24 minutes of waiting too long?

> I hope now you can understand what my problem is.
no, not really.

anyhow:

> <p>James, <br />Andy, <br />Candy</p>
this is actually what i thought you are trying to achieve after
reading this:
>i used "gsub" method to replace \r\n to <br/>

now, i don't know what your data looks like, but you surely could use
split! to split a string into several parts and output the resulting
array like this:

  names_array.each { |name| puts name }

which would give you what you want:
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 14:33
(Received via mailing list)
:) , that was not an issue of waiting actually I thought my emails are
going
some where else due to this message of boxbe, so thats why.

Now come to real issue, actually Mayer i have a text area for entering a
list of developers or list of anything like this
1. Abcd
2. this is my second line
3. this is my third line
now whenever i want to display this thing as a list it comes to me like
a
paragraph,
i tried these
simple_fromat(@vteam.developers)
and
simple_fromat(sanitize(@vteam.developers))
and
(@vteam.developers).gsub("\r\n","<br/>")
but none these worked.

Thanks,
Shahroon
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 14:55
(Received via mailing list)
Okay thanks, I got the solution.
thats simply
(@vteam.developers).gsub("\n","<br/>")

Shahroon
4c438a80fc30661ad619ea177cf9cbd0?d=identicon&s=25 Freddy Andersen (Guest)
on 2009-02-23 17:19
(Received via mailing list)
Why don't you just do a team has_many developers and add a text_field
with developers that can be added??? Entering the developers in a text
area as a list does not sound like a good idea...

If you had many developers you would just create the list with
team.developers.each and you are golden...
5b6e58cabeba80bc6faf29b7f45aa622?d=identicon&s=25 shahroon ali (Guest)
on 2009-02-23 17:28
(Received via mailing list)
I know you are right, and I convinced my client as well but he insist me
to
do like this.

Thanks,
Shahroon
This topic is locked and can not be replied to.