# Mapping Table Names to Human Names for Display

**URL:** <https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818>\
**Category:** Rails\
**Created:** [December 20, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818 "2007-12-20T22:39:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 20, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/1 "2007-12-20T22:39:01Z")

</div>

Using Scaffolding, in SHOWING data, it shows the table name (called the  
human name) and valve, when showing data. I would like alter the  
table/human name.

Is there an easy way to do this, or should i make my own  
mapping hash table?

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 20, 2007, 11:50pm UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/2 "2007-12-20T23:50:23Z")

</div>

What?

Shouldn’t it be editable in a view somewhere?  
app/views/layouts/your\_controller.rhtml or app/views/your\_controller/\*  
to  
begin with.

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 12:19am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/3 "2007-12-21T00:19:39Z")

</div>

Ryan B. wrote:

> What?
> 
> Shouldn’t it be editable in a view somewhere?  
> app/views/layouts/your\_controller.rhtml or app/views/your\_controller/\*  
> to  
> begin with.

na.  
the EDIT pulls up a form.  
the SHOW command grabs the column name.

here is the basic code for a SHOW:

\<% for column in Text.content\_columns %\>

**\<%= column.human\_name %\>:** \<%=h @casefile.send(column.name) %\>

\<% end %\>

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 12:43am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/4 "2007-12-21T00:43:41Z")

</div>

I still don’t get what you’re trying to do.

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 1:06am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/5 "2007-12-21T01:06:20Z")

</div>

Ryan B. wrote:

> I still don’t get what you’re trying to do.

Well, if my sql table, as a column named goofypants,  
right now it displays, after scaffolding:

goofypants: ME

i want it to display

Goofy Pants: ME

i was wondering where to change that,  
or to make a hash for table name conversion.

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 1:55am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/6 "2007-12-21T01:55:14Z")

</div>

Ryan B. wrote:

> Aha! Ruby has no way of knowing how to titleize a column name such as  
> that.  
> However, if your column was goofy\_pants it would not have a problem.  
> Simply  
> call column\_name.titleize.
> 
> –  
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)

now i feel like goofy.  
i wish i had known that.

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 1:14am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/7 "2007-12-21T01:14:40Z")

</div>

Aha! Ruby has no way of knowing how to titleize a column name such as  
that.  
However, if your column was goofy\_pants it would not have a problem.  
Simply  
call column\_name.titleize.

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 2:00am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/8 "2007-12-21T02:00:11Z")

</div>

Ryan B. wrote:

> ## That’s ok. We were all noob once. Even matz.
> 
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)

i converted 6 tables, and it works GREAT.  
thanks.

---

<div class="post-metadata">

**Author:** ![gemblon](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ee59a6/32.png) [@gemblon](https://www.ruby-forum.com/u/gemblon)\
**Post date:** [December 21, 2007, 1:57am UTC](https://www.ruby-forum.com/t/mapping-table-names-to-human-names-for-display/123818/9 "2007-12-21T01:57:20Z")

</div>

## That’s ok. We were all noob once. Even matz.

Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!
