You need to install libmagickwand-dev in order to successfully complete the rmagick gem. Following command will do the job for you:
sudo apt-get install libmagickwand-dev
On a Mac, you would run the following command:
brew install imagemagick # it requires you to install Homebrew first.