# Newbie q: Truncate text field

**URL:** <https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200>\
**Category:** Rails\
**Created:** [December 14, 2005, 4:47am UTC](https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200 "2005-12-14T04:47:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 14, 2005, 4:47am UTC](https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200/1 "2005-12-14T04:47:00Z")

</div>

I’m trying to incorporate a field where a user can enter a quantity  
(online store app). I’ve tried adding this to my  
views/onlinestore/index.rhtml:

 \<%= text\_field 'line\_items', 'quantity' %\> 

(I’m a total newbie so if there is a better way to pass the qty for an  
online order please do suggest!)

That does indeed put a quantity field where I want it but it’s pretty  
big. Changing the length of the dbase field doesn’t reduce it. Ideally  
I’d like it big enough to enter 3 digits and that’s it. How can I do  
that?

Thanks in advance…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 14, 2005, 7:28am UTC](https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200/2 "2005-12-14T07:28:43Z")

</div>

> \<%= text\_field ‘line\_items’, ‘quantity’ :size=\>3%\>

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 14, 2005, 4:33pm UTC](https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200/3 "2005-12-14T16:33:04Z")

</div>

bruce balmer wrote:

> > \<%= text\_field ‘line\_items’, ‘quantity’ :size=\>3%\>

Ok, I got it, full line of code ended up being:

\<%= text\_field 'line\_items', 'quantity',{: size=\>3} %\> 

Thanks Bruce!

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [December 14, 2005, 8:52pm UTC](https://www.ruby-forum.com/t/newbie-q-truncate-text-field/50200/4 "2005-12-14T20:52:36Z")

</div>

Vince:

You’re welcome. Odd thing is that you don’t need those curly braces  
around :size=\>whatever. Maybe it is correct form and maybe it is  
important and MAYBE I am lucky that my sites are working.

Anyone care to comment?

bruce
