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
# 여기에 붙여넣기

먼저 백업을 만들어 두는 것이 좋습니다.

2개의 좋아요