# Mapping Column Names in Rails

**URL:** <https://www.ruby-forum.com/t/mapping-column-names-in-rails/140162>\
**Category:** Rails\
**Created:** [June 11, 2008, 2:11pm UTC](https://www.ruby-forum.com/t/mapping-column-names-in-rails/140162 "2008-06-11T14:11:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tktktk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@tktktk](https://www.ruby-forum.com/u/tktktk)\
**Post date:** [June 11, 2008, 2:11pm UTC](https://www.ruby-forum.com/t/mapping-column-names-in-rails/140162/1 "2008-06-11T14:11:58Z")

</div>

Hi

We have a legacy database that we want to be able to access through  
rails without changing the database. But within rails we would like to  
be able to work with easier attributes, for example:

Database Column Rails  
CUSTOMER\_LASTNAME lastname

Can we accomplish this by any means?

Thanks.

---

<div class="post-metadata">

**Author:** ![tktktk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a3d4f5/32.png) [@tktktk](https://www.ruby-forum.com/u/tktktk)\
**Post date:** [June 11, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/mapping-column-names-in-rails/140162/2 "2008-06-11T14:26:20Z")

</div>

On 11 Jun 2008, at 13:09, tk wrote:

> Can we accomplish this by any means?

define your own accessors (that call read/write\_attribute or use []/[]=

Fred
