Topic: HABTM and ferret with rails

I looked all over the internet to try to find a solid way to do this, but to no avail. I pieced together some other people's incomplete attempts and this is what I came up with:

A video has and belongs to many tags


class Video < ActiveRecord::Base
  acts_as_ferret :additional_fields => [
            :tag_name
          ]
  has_and_belongs_to_many :tags, :uniq => true

  def tag_name
    return self.tags.collect {|t| t.name}.join(" ")
  end

Worked like a charm!