After some more google searching i have found a solution.
first i made the user class look like this:
class User
include MongoMapper::Document
key :username, String
key :password, String
key :name, String
key :companyID
key :groupID
timestamps!
end
then the group and company class like this:
class Company
include MongoMapper::Document
key :name, String
timestamps!
end
class Group
include MongoMapper::Document
key :name, String
key :accesLevel, Integer
timestamps!
end
With these classes in place i changed my controller to first create a company and then a group these could also be loaded but for the ease of testing it was not necessary to do this so that i didn't need to write the code for this.
company = Company.new
company.name = "comp"
group = Group.new
group.name = "admin"
user = User.new
user.name = "user1"
user.username = "user1"
user.password = "passuser1"
user.groupID = group.id
user.companyID = company.id
db_config = YAML::load(File.open('./dbconfig.yml'))
MongoMapper.connection = Mongo::Connection.new(db_config['hostname'])
MongoMapper.database = db_config['name']
company.save
group.save
user.save