Skip to content

Instantly share code, notes, and snippets.

@jney
Created February 23, 2009 11:13
Show Gist options
  • Save jney/68910 to your computer and use it in GitHub Desktop.
Save jney/68910 to your computer and use it in GitHub Desktop.
found_records = []
ActiveRecord::Base.connection.tables.each do |table|
klass = table.classify.constantize rescue next
klass.send(:columns).select{|col| col.type == :string}.collect(&:name).each do |column|
res = klass.all(:conditions => ["`#{table}`.#{column} like ?", "%bocrgk%"])
found_records << res if res.any?
end
end
p found_records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment