Move formaturl code from controller to model.