# Formating default data for text fields

**URL:** <https://www.ruby-forum.com/t/formating-default-data-for-text-fields/125291>\
**Category:** Rails\
**Created:** [January 7, 2008, 11:13pm UTC](https://www.ruby-forum.com/t/formating-default-data-for-text-fields/125291 "2008-01-07T23:13:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![student](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ecc23a/32.png) [@student](https://www.ruby-forum.com/u/student)\
**Post date:** [January 7, 2008, 11:13pm UTC](https://www.ruby-forum.com/t/formating-default-data-for-text-fields/125291/1 "2008-01-07T23:13:24Z")

</div>

Here’s my setup:  
In migration file:

…  
t.column :perm0, :int, :default =\> User::Perms::Base, :null =\> false  
…

(User::Perms:Base = 1)

In app/views/login/add\_user.rhtml:  
…  
Permissions:  
\<%= form.text\_field :perm0, :size =\> 10 %\>  
…

While (quite magically), provides me with a form with the default  
value “1” helpfully prefillled.

The fly in the ointment is that, should I decide on a more interesting  
default, I’m going to want the value displayed zero-filled in hex  
(%08x instead of %d). Any ideas?

===

Alternatively, I could go with a checkbox system, with the checkboxes  
preset according to the default. Where is the magic that pulls this  
data out of the db?
