Garageband is a doddle to use & I've found the best results are from taking a cable with a 1/4 jack on one end (plugged into bass) & a 3.5mm jack on the other (plugged into the socket on the back of the iMac).
Open up GB & create new song (giving it the title you want), then on the top bar click Track > New Track > Real Instrument Track & click Create.
On the new track that 's been created, it will have 5 icons (at the far left under the track name, which is probably "No Effects"). The first is a • , Click it so it goes red.
At the Right of the screen there is a panel called "Track Info". At the bottom of the screen it says "Details", Click the arrow.
Now choose your input source (if it just comes up "Mic" then you need to go to the top bar, click Garageband > Preferences > Audio/Midi & choose from the dropdown). Back to the "Track Info" pane, make sure your volume isn't turned full whack & click the Monitor dropdown & select On.
If you have any trouble with the rest, let me know.