For this and the "general" definition to coincide, the ring in question has to be a unique factorization domain, which the integers are an example of. In any bigger subset of rings (integral domains or general commutative rings), there are rings for which this doesn't hold.