Skip to content

Instantly share code, notes, and snippets.

@dhirajbajaj
Created June 11, 2015 13:05
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 dhirajbajaj/fadc81d30f1dad3b518b to your computer and use it in GitHub Desktop.
Save dhirajbajaj/fadc81d30f1dad3b518b to your computer and use it in GitHub Desktop.
Rails remove multiple columns except few
tbr_models = Model.column_names - ['id', 'name', ... , 'created_at', 'updated_at']
tbr_models.each do |model_column|
remove_column :models, model_column
puts "-- #{model_column}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment