# Column names

**URL:** <https://www.ruby-forum.com/t/column-names/187744>\
**Category:** Rails\
**Created:** [April 28, 2010, 6:30pm UTC](https://www.ruby-forum.com/t/column-names/187744 "2010-04-28T18:30:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 28, 2010, 6:30pm UTC](https://www.ruby-forum.com/t/column-names/187744/1 "2010-04-28T18:30:24Z")

</div>

Is there a function that can be called on an object that returns a  
hash of the colum names (i.e. attributes) of the object?

---

<div class="post-metadata">

**Author:** ![ESESES](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/f0a364/32.png) [@ESESES](https://www.ruby-forum.com/u/ESESES)\
**Post date:** [April 28, 2010, 6:46pm UTC](https://www.ruby-forum.com/t/column-names/187744/2 "2010-04-28T18:46:47Z")

</div>

On 28 April 2010 17:28, ES [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is there a function that can be called on an object that returns a  
> hash of the colum names (i.e. attributes) of the object?

There’s a few that might do what you want. Have a look at:

> **[ActiveRecord::Base](https://api.rubyonrails.org/classes/ActiveRecord/Base.html)**
>
> Active Record Active Record objects don't specify their attributes directly, but rather infer them from the table definition with which they're linked.

Look particularly at:  
Model.content\_columns  
Model.columns  
Model.column\_names  
Model.columns\_hash
