To discover the minimum set of tools and libraries you'll need, I started with a completely fresh archlinux/base image in Docker as follows:
docker run -it archlinux/base
...and now inside the container...
First of all I changed out the default mirrorlist as the mirror in the image didn't seem to work. If your pacman is working fine you don't need to do this.
rm /etc/pacman.d/mirrorlist
echo "Server = http://mirrors.kernel.org/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
pacman-db-upgrade
pacman -Syyu --noconfirm
Next, I installed ruby and the C++ tools.
pacman -S ruby gcc make --noconfirm
Attempting to run gem install rails -- --use-system-libraries led to the expected complaints about missing libraries for Nokogiri. It depends on libxml2 and libxslt, so...
pacman -S libxml2 libxslt --noconfirm
Finally you can run gem install rails -- --use-system-libraries and it will finish successfully.
If you want to install rails without --use-system-libraries (which is probably what you want, as Nokogiri laments about not being 100% compatible with OS-bundled versions of libxml2) just install git and awk through pacman instead of installing the xml libraries, e.g.
pacman -S ruby gcc make git awk --noconfirm
gem install rails
Enjoy!