Replace a string in all posts

Topics.where(category_id: 123).each do |t|
  posts.where(topic_id: t).each do |p|
    p.raw.gsub!("replaceme","/")
    p.save
  end
end
./launcher enter app
rails c
# paste in the stuff

You might make a backup first.

2 Likes