Created
March 3, 2017 20:55
-
-
Save foxumon/c032b68d8b9df90a6ffae945a4095b04 to your computer and use it in GitHub Desktop.
Global replace in RoR console
This file contains hidden or 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
a = MODEL.where("COLUMN like ?", "%SEARCH%");0 | |
puts a.length | |
puts " " | |
a.all.each do |a| | |
puts a.id | |
end;0 |
This file contains hidden or 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
ActiveRecord::Base.connection.execute(%q{ | |
update TABLE | |
set COLUMN = replace( | |
COLUMN, | |
'BAD', | |
'GOOD' | |
) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment