Use has_and_belongs_to_many if you just need to link users to groups. Use has_many :through if you need to store additional membership information.
Example:
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
end