Rails: user agent discovery works in development but not in production?

I am trying to detect Blackberry user agents in my application, which works fine in my development version. But nothing happens when I redeploy the application during production.

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> 

I tried to clear the cache using rake tmp: cache: clear and restart mongrel several times. HTTP_USER_AGENT seems to be back in production. I am using Nginx with the mongrel clan.

+6
ruby ruby-on-rails
source share
2 answers

Do you use Apache or nginx in front of your mongrels?

Are you registering user_agent? This is from my 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"'; 
+2
source share

Try:

 request.user_agent 
+44
source share

All Articles