Ruby: Unable to Create Ruby on Rails Application at cPanel

When you receive the error as below when try to create Ruby on Rails application on cPanel. It mean that your rails/ruby version installed is not supported by cPanel.

Your app is NOT installed because there was a problem. Try again or contact
our support team.

So the solution will be remove the current Ruby and Rails and install it by cPanel build in script. Moving the unsupported Ruby and Rails environment and then reinstalling using the proper cPanel script should setup the machine with the right Rails version and mongrel.

(1) Remove the unsupported Ruby and Rails

mv /usr/bin/ruby /usr/bin/ruby.bak
mv /usr/lib/ruby /usr/lib/ruby.bak
mv /usr/bin/gem /usr/bin/gem.bak
mv /usr/bin/rails /usr/bin/rails.bak

(2) Install again by cPanel script

/scripts/installruby --force