簡體   English   中英

Rails:檢測用戶代理是否在開發中工作但不在生產中?

[英]Rails: Detecting user agent works in development but not production?

我試圖在我的應用程序中檢測Blackberry用戶代理,這在我的開發版本中工作正常。 但是,當我在生產中重新部署應用程序時,沒有任何反應。

application_helper.rb

  def blackberry_user_agent?
    request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(Blackberry)/]
  end

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>

我已經嘗試使用rake tmp:cache清除緩存:清除並重啟mongrel幾次。 顯然,HTTP_USER_AGENT在生產中回歸為零。 我正在使用Nginx和一個mongrel集群。

嘗試:

request.user_agent

你在你的雜種前面使用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"';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM