I found it quite useful to run this command whenever I reinstall rails on Ubuntu. This usually takes care of the super common zlib and sqlite3 errors.
/ usr / bin / apt-get install build-essential bison openssl libreadline6 libreadline6-dev curl git -core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev devxxlt-dev autoconf libc6-n -dev
source share