Forum: Ruby on Rails .columns refresh

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ryan (Guest)
on 2007-04-20 03:42
I'm trying to iterate through all tables and fields in a mySQL database.


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

        <% Model.set_table_name i %>

  <% for j in Model.columns %>
    Field Name: <%= j.name %><br />
  <% 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] http://api.rubyonrails.com/classes/ActiveRecord/Ba...



Any ideas???

Thank You,

Ryan
This topic is locked and can not be replied to.