There are products such as ngrok which expose your localhost to the web, so you can access it on another machine, for example another laptop or your phone. However, I often find that this method is an overkill for simple testing.
Get your IP address
Search for Network Utility and make a record of your IP address.
Another way to find your IP address is to click on the wifi icon in the menu bar with the option key pressed down. This will give you access to bunch of information, including your IP address.
Start your server
Start your server using
rails server -b 0.0.0.0
This will allow you to access your Rails server from a different machine. You can read more about it here.
Access localhost on your phone
Using your IP address, access your Rails server on another machine using