From 8796b3a415ff53e0bf79a5c030328365aa8156d5 Mon Sep 17 00:00:00 2001 From: Logan Fick Date: Fri, 24 Nov 2017 22:01:37 -0500 Subject: [PATCH] Made user profile page show hostname of user's IP address. --- app/controllers/users_controller.rb | 6 ++++++ app/views/users/show.html.erb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 66b07fd..e86db8b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -22,6 +22,12 @@ class UsersController < ApplicationController flash.now[:alert] = "An error occured while checking if this user is banned from the server!" @ban_json = nil end + + begin + @hostname = Resolv.new.getname(@user.last_ip) + rescue + @hostname = "No hostname found." + end end # SIGNUP diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index cafe726..8726f8e 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -85,7 +85,7 @@ <% if mod? || @user.is?(current_user) %> Last IP - <%= @user.last_ip %> + <%= @user.last_ip %> (<%= @hostname %>) Email