I upgraded to El Capitan, with Homebrew & Ruby, and this is how I did it flawlessly.
... and Xcode and Java, etc.
If you don't already have homebrew installed, do that first, so you don't have to deal with SIP issues. Install all Software Updates available in the Apple Menu, up to and including El Capitan.