You need to install the development tools. On Ubuntu this would be
the package build-essential, plus some others. I don't know whether
it will help but googling for
install ruby rails qnap
found this  and others
If possible I suggest that you use rvm to install RoR.