Strange behavior of Source.column_names


#1

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 ?


#2

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.