I’m on my phone. Here are some parts
posts = Post.where("raw like '%badword%')
posts.each do |post|
Tag.create(some stuff here) # this won't work
end
If there are lots of words, you’d stick them in an arrays and loop through them. You’ll need to find an example of what fields are required to create a tag. Probably topic_id and name.