In Rails, how to get current url (but no paths)
request.host
should do the trick, or:
request.port.blank? ? request.host : "#{request.host}: #{request.port}"
if you need to include the port too.
You can use this
<%= request.protocol + request.host_with_port %>
#=> https://domain.example:3000
<%= request.protocol + request.host %>
#=> https://domain.example
Starting from Rails 3.2 you can also use
<%= request.base_url %>
#=> https://domain.example:3000