Last active
August 29, 2015 14:26
-
-
Save tarky/ce3dd5c0799f9bb6a437 to your computer and use it in GitHub Desktop.
destory item without user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models = %w(Theme Entry Vote Activity Feed Follow Notification Authentication) | |
models.each do | model | | |
model.constantize.all.each do | obj | | |
if obj.user.nil? | |
puts "User #{obj.user_id} doesn't exist. So destroy #{model} #{obj.id}" | |
obj.destroy | |
end | |
end | |
end | |
Follow.all.each do | obj | | |
if obj.user.nil? | |
puts "Followed #{obj.followed_id} doesn't exist. So destroy Follow #{obj.id}" | |
obj.destroy | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment