Ruby on Rails OS X El Capitan

If you get following error

sudo gem install rails --version 4.2.6
ERROR:  While executing gem ... (Gem::Exception)
    Unable to require openssl, install OpenSSL and rebuild ruby (preferred) or use non-HTTPS sources

do following

gem source -r https://rubygems.org/

gem source -a http://rubygems.org/
https://rubygems.org is recommended for security over http://rubygems.org/

Do you want to add this insecure source? [yn]  y
http://rubygems.org/ added to sources

Then, install rails

sudo gem install rails --version 4.2.6