Rails Mysql Results - fetch_fields method
So I'm trying to get the column names from the sql results using the method fetch_fields. But that returns it in this odd way:
> for keys in e.fetch_fields.each do
> puts keys
> end
#<Mysql::Field:0x1c2a7bc>
#<Mysql::Fie开发者_JS百科ld:0x1c2a780>
#<Mysql::Field:0x1c2a744>
=> [#<Mysql::Field:name>, #<Mysql::Field:address>, #<Mysql::Field:city>]
How do I get it to show as name, address, city?
Found that this is the correct way to get the names of each field:
> for keys in e.fetch_fields.each do
> puts keys.name
> end
精彩评论