get server address (rails server)

Answering the question #1 you can achieve this using the request.env[
'HTTP_HOST' ] variable, that will return you a string with the hostname
and the listening port, something like 'localhost:8080'.
For the second one, I guess you could create like some constants for
storing those keys of your needs, but you're not being very clear so I
can not go further. Hope this can help you.

Carlos.