I want to register a callback URL to my Rails server from a third-party application, and to perform this registering on startup so I can start catching notifications.
Looking at this question and the answers I see advice like:
class SomeController < ApplicationController
def some_action
raise "I'm running on port #{request.port}."
end
end
This is no good as I am not in a Controller. Next there is:
Rails::Server.new.options[:Port]
However, I get this error from my code and rails console
:
NoMethodError: undefined method 'Server' for Rails::Module
I've got the host name successfully using Socket.gethostname
, but how do I get the port number?