Last active
March 10, 2022 09:01
-
-
Save andyjeffries/a534ef6d50ad145a902d439906958d38 to your computer and use it in GitHub Desktop.
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
objects = [MyObject.new(name: "John Smith"), MyObject.new(name: "Joan Smith"), MyObject.new(name: "Jane Doe")] | |
objects.select {|o| o.name["Smith"]}.each do |o| | |
o.name.gsub!("Smith", "Jones") | |
o.save | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also, I'm assuming you're not using ActiveRecord... If you are then you'd do something like this: