For those who have problems with @lamech-desai answer, (actually, when they do Desai’s commands, it apparently works temporarily for them).
So you can easily do these:
open ~/.bashrc if you would like to use bash or ~/.zshrc if your are using zsh or etc…
$ nano .bashrc ## bash users
$ nano .zshrc ## zsh users
then copy and past these two lines of code at the end of the .*rc file:
export GEM_HOME="$(ruby -e 'puts Gem.user_dir')"
export PATH="$PATH:$GEM_HOME/bin"
then simply press ctrl+s and ctrl+x. This will save the changes to .bashrc but you won’t see them immediately – directly on your next shell login with your current user. One way to see the changes immediately is to type source .bashrc – and voila, your .bashrc will be reloaded. You can also check this with echo $PATH.
Thanks to @lamech-desai for great answer