Hello there and happy holidays.
I’m not sure if the surprise for what I’m seeing in my forms is
justified, but I am very surprised, so here’s the thing.
-
I have a simple model with a single text field named ‘content’.
-
I run the app and create a new record.
-
I write “one two three four” into the ‘content’ textarea and save the
record. The text is properly displayed by the “show” action. -
Now I edit the same record (or create a new one, it doesn’t matter),
this time entering
one
two
three
four
i.e. newline-separated strings. As expected, the saved record is
displayed inline as the previous one, if no extra processing (such as
textile or markdown) is done on the output.
- Now, edit the record, look at the textarea field, and here’s the weird
thing (to me at least)
one
two
three
four
I’m hoping that the post will retain the layout of what I’ve just typed,
i.e. the text passed to the textarea through the model’s instance
variable is split into four lines, with A BUNCH OF WHITESPACE BEFORE
EACH LINE, except for the first.
If I update the record without touching the textarea, this whitespace
will be saved as well. Editing and updating again and again the record
results in the three lines being moved further and further off to the
right, with the size of the record growing accordingly, as shown through
the console.
Am I missing something quite obvious?
So sorry to have bothered you all if I am.
Cheers and thanks in advance,
Giuseppe