(Geologist here, although not an ore expert.) This is neither literally true nor particularly accurate. You are more correct in that it is related more broadly to magma (by definition not released by volcanoes, as it would then be lava; magma is subterranean).

The metals in most ore deposits are, originally, present in magma but concentrated in solution in superheated fluids (mostly water, but also CO2, H2S, H3SO4, etc., or any chemically stable mix of these). These fluids are expelled from magma as the magma cools and are mobilized through fracture networks and pore spaces in the ambient rock, both in the igneous rocks that have just cooled and crystallized, as well as in the surrounding rocks. As the fluids cool, the metals (and other solutes) come out of solution and precipitate as minerals. Some of these will be 'native' gold, copper, etc. that are mostly pure metals, but with the exception of gold, most of the metals will be in different oxides, silicates, sulfides, and other compounds.

These minerals may be re-dissolved at any time in the geologic future when conditions are right. This is usually when there is infiltration of hot, potentially acidic fluids deep in the crust from later magmatism or other geologic processes (the rock could be buried many kilometers during sedimentation or mountain building episodes, which will heat it up dramatically). The re-mobilized fluids can travel tens or hundreds of kilometers along fracture networks in the crust, and then as they cool, they re-deposits the ore as new minerals (not necessarily the same type). This can, and does, happen repeatedly so that the ore deposits of interest could be many generations, thousands of kilometers and millions of years from the original magmatic source.

In other instances the ores may form at the Earth's surface due to weathering of rock that contains the elements of interest. The most prominent example is probably aluminum ore, which is typically a rock called bauxite that was originally a soil formed from the weathering of highly aluminum-rich igneous rocks in tropical conditions. Bauxite requires an enormous amount of processing to separate out the aluminum, which is why aluminum recycling is so economical. The energy requirements for bauxite refining are enormous so the ore has historically been transported halfway across the world from the tropics to places like the Columbia River hydropower facilities in the US Northwest and the geothermal powerhouse of Iceland (this is part of why Seattle became an aerospace center).

The prodigal gold and silver mines of the Sierra Nevada are also the result of surface weathering. The ore (I think mostly native silver and gold but I am not sure) was actually in little flakes in river beds in Nevada some 40 million years ago when Nevada was a high plateau higher than the Sierra (which was probably not as high then); the rocks in the river headwaters weathered to sand and clay and little bits of metals, and the rivers spilled down into California and left big sedimentary deposits at the base of the mountains, big alluvial fans and stuff. Then Nevada got broken apart by tectonics into a bunch of rifts and the rivers went away. The California miners just had to separate the very heavy gold and silver particles from the much lighter sand and gravel using flumes, rather than crushing and chemically separating solid ore like we typically think of with mining.