I have a table with an column "Ip" all has the values like 10.x.x.x, now I want to replace the 10 with 20 of all the records. Is their any way to do this via Activerecord or Do I need to execute only raw postgres query with regexp_replace?
ModelName.update_all("column_name = replace(columnname,'originaltext','replacement') ")
Eg:
Resource.update_all("fqdn = replace(fqdn,'d3p5','d6p6') ")
Now all the occurrences of "d3p5" of fqdn column replaced with d6p6
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With