I succeeded in installing the Rails version with Ruby on Rails, but when I started the Rails application, the installation of ffi failed as shown below. I will leave the remedy I took at that time.
An error occurred while installing ffi (1.13.1), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.13.1' --source 'https://rubygems.org/'` succeeds before bundling.
Probably due to the Mojave environment of MacOS. As for the cause, it seems that there is no ffi when installing Ruby with Homebrew.
First, reinstall libffi for Mojave because you don't have ffi. Reinstall using the following method.
brew reinstall libffi
However, at present, the libffi path is invisible, so specify it.
export LDFLAGS="-L/usr/local/opt/libffi/lib" && \
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" && \
bundle install
Now the ffi installation error is gone and the rails application is running!