# How to display integer fields

**URL:** <https://www.ruby-forum.com/t/how-to-display-integer-fields/72967>\
**Category:** Rails\
**Created:** [October 20, 2006, 8:07am UTC](https://www.ruby-forum.com/t/how-to-display-integer-fields/72967 "2006-10-20T08:07:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 20, 2006, 8:07am UTC](https://www.ruby-forum.com/t/how-to-display-integer-fields/72967/1 "2006-10-20T08:07:07Z")

</div>

How do I override Ruby’s default functionality of not displaying  
integer database fields? I have a database table that has a client\_id  
field that contains an integer that corresponds to the clients table id  
field. The database does not have a foreign key set in place. The  
client\_id field in the table I am searching is just and INT. When I do  
a find(:all) on the table, only the text/varchar fields are returned in  
the code.

Obviously, I am a newbie to Ruby. I appreciate any down to earth help  
you can give me. I want the query I am doing to return the client\_id  
field value so I can do some comparisons.

Thanks!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 20, 2006, 9:31am UTC](https://www.ruby-forum.com/t/how-to-display-integer-fields/72967/2 "2006-10-20T09:31:20Z")

</div>

removed\_email\_address@domain.invalid wrote:

> How do I override Ruby’s default functionality of not displaying  
> integer database fields? I have a database table that has a client\_id  
> field that contains an integer that corresponds to the clients table id  
> field. The database does not have a foreign key set in place. The  
> client\_id field in the table I am searching is just and INT. When I do  
> a find(:all) on the table, only the text/varchar fields are returned in  
> the code.

There’s no reason that it shouldn’t return that column, and you should  
be able to access it the same as any other attribute:

your\_object.client\_id

Does that work?

Chris

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 20, 2006, 3:26pm UTC](https://www.ruby-forum.com/t/how-to-display-integer-fields/72967/3 "2006-10-20T15:26:10Z")

</div>

On Oct 20, 3:15 am, “Chris M.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> your\_object.client\_id
> 
> Does that work?
> 
> Chris

The scaffold hides columns with the suffix ‘\_id’ by default.

There are two solutions…

1. change the name so that it doesn’t contain ‘\_id’
2. stop using the scaffold and put the appropriate calls in the  
views…

\_Kevin
