I build a custom plugin that requires user agent, when it’s deployed, it keeps showing an empty value, how to make the plugin able to get the data from discourse?
I’m using discourse v2.9.0.beta1
update:
Just realized, the plugin on discourse didn’t get the original request.
as this piece of code
<%= request.original_url %>
returns an incorrect url (http://example.org) instead of the correct domain. so this is why the user agent is always empty.
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.