-1

In doing development locally, I usually set my host to localhost like this:

default_url_options = { :host => 'localhost',                                                                                       
                        :protocol => 'http',
                        :port => '3000' }

The problem with this is that sometimes I like to test mobile clients by accessing my local rails server (running on our local network). Because Rails creates urls like http://localhost:3000/assets/blahblah.css, I am unable to sufficiently test my set up outside of figuring out my local IP address and putting that in for my host value.

Is there a better way to do this where Rails, easily, determines the local IP address from which I can populate my host value?

Son of the Wai-Pan
  • 12,371
  • 16
  • 46
  • 55

1 Answers1

0

you can use ngrok

and then just run your server:

rails s

(it will open the server with port 3000 by default, you can choose some other port with -p PORT

now run ngrok with the port of your server:

ngrok 3000

you will get an address like: http://7d1f84c4.ngrok.com and now you can access your localhost using this address.

Ziv Galili
  • 1,405
  • 16
  • 20