I remember doing something similir like 4 years ago with ActsAsTree.
There s also an example of how to do it manually here.
Both options will need that parent_id column on your tags table and are really straightforward. Just create a tag.rb in your models folder and extend Tag class.
Ps. Its been a long time, but i remember having to check that there are no loops, just keep it in mind