Error on installation of Ruby On Rails on QNAP TS809U-RP [Linux]

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 [1] and others

If possible I suggest that you use rvm to install RoR.