Print "all column name and content in sql obj"


#1

hi all,

i have a sql obj

(in controller)
ex: @c = C.find_by_sql(“select * from a,b”)

and i want to print all content in this sql obj c in view .

is there a better way or easy way to print all column name(scheme) in @c
with a table in


and just to print all content in @c with a table in ?

my orginal way :

<% # may i just print all column name in @c with just a iterator ? %>

<% for c in @c %>

<% # may i just print all content in @c with just a iterator ? %>

<%end%>
a b c
c.a c.b c.c

thanks


#2

<% for column in {tablename}.content_columns %>

<%= column.human_name %>
<% end %>

This is all.


#3

nicolas55ar wrote:

<% for column in {tablename}.content_columns %>

<%= column.human_name %>
<% end %>

This is all.

thanks, but it works only with “table”,

and i want to take with “query result”,

ex: @c = C.find_by_sql(“select * from a,b”)