It’s going to be hard to install a new plugin on such an old instance.
Are you sure that Rails needs to know the user agent, and not just the front end (that has easy access to the current browser)? Can you say that you are trying to do?
But here’s a way to get a user agent that has been used by a particular user. It might not be the current user_agent.
u=User.find(1);
uat=UserAuthToken.find_by(user_id: u.id);
uat.user_agent