In 1840, California was part of Mexico and gold wasn't discovered (in large quantities) until 1848. CA had a very small population in 1840 with even fewer foreigners including Americans, English/Irish, Russians, etc.
There wasn't much migration to CA in 1840, but those that did migrate, went there basically to get away from "civilization" and make a new start on life. Mexican authorities did not have much control so CA was pretty much self-governing.
There you go Hope that helped.