Implementation of Many to many relationships in ruby on rails