How to display a string in correct format as i enter it in the textarea in ruby on rails?
actually i enter some string in the textarea as:
my name
is jamal.now there is a next line starting after name... but i get the following in the view...
my name is jamalwhich i don't want to be like that... so, how to get the correct format..?
i hope u understand...
views:
26answers:
2
A:
If you're including the string within a textarea in the view then that is odd. However, if you are just printing the string to the page, then you will need to replace newline characters with "<br/>" tags.
Graphain
2010-06-11 07:38:59
how em i gonna do that... as i enter this in the textarea..?
Jamal Abdul Nasir
2010-06-11 07:41:34
+2
A:
take a look at simple_format method
i.e. <%= simple_format(params[:text]) %>
or <%= simple_format(@text) %>
in your erb/rhtml view code
zed_0xff
2010-06-11 07:41:21
if it works for you please consider accepting the answer for this question.
Salil
2010-06-11 09:34:15