# Strange behavior of Source.column\_names

**URL:** <https://www.ruby-forum.com/t/strange-behavior-of-source-column-names/161722>\
**Category:** Rails\
**Created:** [March 1, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/strange-behavior-of-source-column-names/161722 "2009-03-01T18:16:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [March 1, 2009, 6:16pm UTC](https://www.ruby-forum.com/t/strange-behavior-of-source-column-names/161722/1 "2009-03-01T18:16:57Z")

</div>

I have a class named Source and a controller named SourceController  
etc.

When I use Source.column\_names in the view all names except names  
ending in \_id is listed, although according to the documentation all  
names should be listed

When I use Source.column\_names in the source controller it lists  
correctly all names also the ones ending in id.

When I first call Source.column\_names in the controller then it lists  
all names also in the view when I use Source.column\_names.

Is this a bug in rails ?  
Is the calls Source reserved ?  
Has anyone had the same problem ?  
Is there anyway to solve this problem in a better way than the fisx I  
use by first calling Source.column\_names in the controller ?

---

<div class="post-metadata">

**Author:** ![marmolin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/71e660/32.png) [@marmolin](https://www.ruby-forum.com/u/marmolin)\
**Post date:** [March 2, 2009, 10:34am UTC](https://www.ruby-forum.com/t/strange-behavior-of-source-column-names/161722/2 "2009-03-02T10:34:04Z")

</div>

i really can’t answer your questions regarding why this happens, but  
for the HOW\_TO part i’d suggest to just do it like this:

# controller:

@columns = Source.column\_names

# view:

\<%= @columns %\>

this respects MVC.
