Let''s say I want to find out what column names exist in two tables,
table_a and table_b.
One way I''ve been doing this is using ActiveRecord and the column info
it returns. After establishing a connection for ActiveRecord, I do the
following:
ActiveRecord::Base.set_table_name("table_a")
column_names_a = ActiveRecord::Base.column_names
ActiveRecord::Base.set_table_name("table_b")
column_names_b = ActiveRecord::Base.column_names
The problem I have is that once I set the table_name to
''table_a'',
ActiveRecord always returns table_a''s column info. I''ve tried
the
following ActiveRecord methods to clear the info in column_names &
neither has worked
ActiveRecord::Base.reset_column_information
ActiveRecord::Base.remove_connection
Even after removing & then restablishing the connection, the
column_names method continues to return table_a''s columns.
So I''m obviously on the wrong track here. But I can''t find out
where I
should be headed. Any ideas?
Thanks!
Versions being used:
Ruby 1.8.4
RoR 1.1
--
Posted via http://www.ruby-forum.com/.