# .columns refresh

**URL:** <https://www.ruby-forum.com/t/columns-refresh/92499>\
**Category:** Rails\
**Created:** [April 20, 2007, 1:42am UTC](https://www.ruby-forum.com/t/columns-refresh/92499 "2007-04-20T01:42:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ryan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a8b319/32.png) [@ryan](https://www.ruby-forum.com/u/ryan)\
**Post date:** [April 20, 2007, 1:42am UTC](https://www.ruby-forum.com/t/columns-refresh/92499/1 "2007-04-20T01:42:56Z")

</div>

I’m trying to iterate through all tables and fields in a mySQL database.

\<% for i in Model.connection.tables %\>  
Table Name: \<%= i %\>

```
    <% Model.set_table_name i %>

```

\<% for j in Model.columns %\>  
Field Name: \<%= j.name %\>  
  
\<% end %\>

\<% end %\>

I’m using: Model.connection.tables to get an array of table names, and I  
change the table\_name in a Model, then try to iterate through it’s  
columns.

However… it seems that Model.columns is only calculated once, because  
I’m only getting the fields of the 1st table to show up under every  
table name.

I’ve tried looking at the reload()[1], with no luck

[1] [Peak Obsession](http://api.rubyonrails.com/classes/ActiveRecord/Base.html#M001052)

Any ideas???

Thank You,

Ryan
