Skip to content

Instantly share code, notes, and snippets.

@foxumon
Created March 3, 2017 20:55
Show Gist options
  • Save foxumon/c032b68d8b9df90a6ffae945a4095b04 to your computer and use it in GitHub Desktop.
Save foxumon/c032b68d8b9df90a6ffae945a4095b04 to your computer and use it in GitHub Desktop.
Global replace in RoR console
a = MODEL.where("COLUMN like ?", "%SEARCH%");0
puts a.length
puts " "
a.all.each do |a|
puts a.id
end;0
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