dMi*_*Mix 6 ruby ruby-on-rails
我试图在我的应用程序中检测Blackberry用户代理,这在我的开发版本中工作正常.但是,当我在生产中重新部署应用程序时,没有任何反应.
application_helper.rb
def blackberry_user_agent?
request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Blackberry)/]
end
Run Code Online (Sandbox Code Playgroud)
application.html.erb
<% if blackberry_user_agent? -%>
<div class="message">
<p>Using a Blackberry? <a href="http://mobile.site.ca/">Use the mobile optimized version</a>.</p>
</div>
Run Code Online (Sandbox Code Playgroud)
我已经尝试使用rake tmp:cache清除缓存:清除并重启mongrel几次.显然,HTTP_USER_AGENT在生产中回归为零.我正在使用Nginx和一个mongrel集群.
你在你的杂种前面使用 Apache 或 nginx 吗?
您正在记录 user_agent 吗?这是来自我的 nginx.conf:
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "http_x_forwarded_for"';
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15021 次 |
| 最近记录: |