Training while sore is perfectly fine and usually beneficial a short while after training, your muscles end up a bit stronger. If you train again during this period, your next period will be slightly stronger again. Repeat this with proper timing over and over again and you'll gain strength in the most efficient way possible. Wait too long and the muscle returns back to a normal state and strength gains are slowed.
Soreness has nothing to do with the effectiveness of your workout. It's more of a side effect, which is actually not well understood. Depending on your training level and workouts, you may still be sore even when your muscles are in the supercompensation period. If this happens, you just need to put up with it and train sufficiently hard to keep the gains coming.
If you are sore to the point that it interferes with the workout (ie, you can't do the motion correctly), then you won't gain much from exercise and are better off resting. A rule of thumb to determine this is to do a thorough warm-up: if everything loosens up and you feel OK, train on. If you are still stiff and it hurts to move, rest. If you are new to a certain type of exercise, soreness levels will be much higher, so the first few weeks may require skipping more workouts than normal (don't make it a habit though). Finally, more advanced lifters who are moving a lot of weight will take longer to recover, which will impact things like workout frequency and volume.