Skip to content

Instantly share code, notes, and snippets.

@sshaw
Last active July 29, 2023 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sshaw/1d860c13d9b22c8e27a954e109072ad6 to your computer and use it in GitHub Desktop.
Save sshaw/1d860c13d9b22c8e27a954e109072ad6 to your computer and use it in GitHub Desktop.
Rails: Print What Models Have Ignored Columns That No Longer Exist in DB (Moved: https://github.com/sshaw/ignored_columns_tasks)
(ApplicationRecord.subclasses + ActiveRecord::Base.subclasses).each do |klass|
next if klass.abstract_class? || klass.ignored_columns.none?
ignored = klass.ignored_columns
klass.ignored_columns = []
klass.reset_column_information
removed = ignored - klass.column_names
klass.ignored_columns = ignored
next unless removed.any?
printf "%s: %s\n", klass.name, removed.to_sentence
end
@sshaw
Copy link
Author

sshaw commented Jul 28, 2023

rails r print-non-existant-ignored-columns.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment