Renaming tags in the rails console

Use at your own risk!

Do this after you have renamed #foo to #bar

Post.where("raw like '%#foo%'").each do |p|
  p.raw = p.raw.gsub(/#foo\b/, '#bar')
  p.save!
end