Forum: Ruby on Rails leading blanks in text areas

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.
91a8d94ad1c54f6e48160b092d3019f8?d=identicon&s=25 jankers (Guest)
on 2007-01-19 16:30
(Received via mailing list)
I've been struggling with this for a while now and I give up.  I
searched and searched but couldn't find the answer either.  My edit
form has a text area with the following HTML
        <p><b>Description</b><br>
          <textarea cols="40" id="workout_description"
name="workout[description]" rows="5" wrap="virtual">
          <%=@workout.description%></textarea> </p>

Whenever the page loads, 10 extra blank spaces are in the text box
before the description. The spaces are not in the database.  If I don't
remove them before saving, the blanks get saved to the database.  Any
ideas on why this is happening?  I changed the code to an input field
and the problem goes away.

Thanks,
jankers
Ea53b1841bf3c1408fe6fc02561dfcc1?d=identicon&s=25 Jamie Wilson (Guest)
on 2007-01-19 16:31
(Received via mailing list)
On 09/01/07, jankers <mikejancola@yahoo.com> wrote:
>         <p><b>Description</b><br>
>           <textarea cols="40" id="workout_description"
> name="workout[description]" rows="5" wrap="virtual">
>           <%=@workout.description%></textarea> </p>
>
> Whenever the page loads, 10 extra blank spaces are in the text box
> before the description. The spaces are not in the database.

Change it to:

<textarea cols="40" id="workout_description"
name="workout[description]" rows="5"
wrap="virtual"><%=@workout.description%></textarea>

(ie, remove the line break after your textarea tag) and you should be
set.

...j
A1a22fbcc528100593e2600f7eaa0ac6?d=identicon&s=25 IsBOF (Guest)
on 2007-09-25 22:43
(Received via mailing list)
If i look at your html code it looks like there are ten spaces after
the start textarea tag and the <%=.....

Rasmus
This topic is locked and can not be replied to.