Forum: Ruby on Rails Strange behavior of Source.column_names

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Hans M. (Guest)
on 2009-03-01 19:16
(Received via mailing list)
I have a class named Source and a controller named SourceController

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 ?
MaD (Guest)
on 2009-03-02 11:34
(Received via mailing list)
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.
This topic is locked and can not be replied to.