When iterating tables with ActiveRecord::Base.connection, how do you check if a string is equal to t

Hey all,

This here is not working:

task(:load_selected => :load_config) do
IgnoreTables = %w(‘students’)
begin
ActiveRecord::Base.establish_connection
ActiveRecord::Base.connection.tables.each do |table|
if IgnoreTables.include? table
puts “Its true”
next
else
ActiveRecord::Base.connection.execute(“TRUNCATE #{table}”)
end

end
end
end

Despite that some point table will be equal to students and students
is in the IgnoreTables array, it should skip to the next iteration,
but rather the else is triggered and the table is truncated.

Anyway know how to address this? Is there a method part of connection
that will help me achieve what I am trying to do?

Thanks for response

On 11 Jul 2011, at 17:51, John M. [email protected] wrote:

Hey all,

This here is not working:

task(:load_selected => :load_config) do
IgnoreTables = %w(‘students’)

I think you’ll find that this array is [“‘students’”] but you expected
it to be [“students”]

Fred