Forum: Ruby on Rails Finding out the port

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3e2f0fd83b12637e15342b171cc960c5?d=identicon&s=25 unknown (Guest)
on 2007-04-27 19:29
(Received via mailing list)
How can a running Rails application tell what port it's listening on?
Say I start the app with 'mongrel_rails -p 3002' and want a page to say
"I'm listening on 3002", how would I do that?
--
Nick
83ca41657a99b65d99889abe712ba5e2?d=identicon&s=25 Jason Roelofs (Guest)
on 2007-04-27 19:42
(Received via mailing list)
http://api.rubyonrails.org/classes/ActionControlle...

In your controller:

request.port

There's also:

request.host                 => "localhost"
request.host_with_port  => "localhost:3000"

Jason
3e2f0fd83b12637e15342b171cc960c5?d=identicon&s=25 unknown (Guest)
on 2007-04-27 20:02
(Received via mailing list)
On 2007-04-27 13:42, Jason Roelofs wrote:
> http://api.rubyonrails.org/classes/ActionControlle...
> M000247
>
> In your controller:
>
> request.port

Thank you.  I realised I should have asked a different question.  Is
there a way to get at the port number independently of a specific
request?  For example, if I want to set something in environment.rb in a
way that depends on the port number.

--
Nick
This topic is locked and can not be replied to.