[LRUG] Rails log_tags in production

Craig R Webster craig at barkingiguana.com
Mon Jul 18 02:22:15 PDT 2016


Hello,

Does the Pingdom bot send `Cookie` headers?

Cheers,
Craig | http://barkingiguana.com/
--
Barking Iguana Ltd. is a company registered in England and Wales.
Registered number: 08915147. Registered address: Jubilee House, East Beach, Lytham, St. Annes, Lancashire, England, FY8 5FT.

> On 18 Jul 2016, at 10:19, Andrew Stewart <boss at airbladesoftware.com> wrote:
> 
> Hello LRUG!
> 
> I am trying to log the current user id in a Rails app via the following configuration:
> 
>  # config/environments/{development,production}.rb
>  config.log_tags = [
>    lambda { |request|
>      session_key = Rails.application.config.session_options[:key]
>      session_data = request.cookie_jar.signed[session_key]
>      user_id = session_data['current_person_id']
>      user_id || 'public'
>    }
>  ]
> 
> This works fine in development but in production, although the site works perfectly for a user, Pingdom immediately reports a 500 error and unicorn.stderr.log shows:
> 
>  app error: undefined method `[]' for nil:NilClass (NoMethodError)
>  /path/to/my/app/releases/20160717162528/config/environments/production.rb:49
> 
> Line 49 is the `user_id = session_data['current_person_id']` one above.
> 
> In production I'm using Rails 3.2 and Unicorn 4.2.0 (behind Nginx 1.6.2).
> 
> Does anyone know why this doesn't work in production for Pingdom's bot?
> 
> Many thanks in advance!
> 
> Yours,
> 
> Andy Stewart
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> Archives: http://lists.lrug.org/pipermail/chat-lrug.org
> Manage your subscription: http://lists.lrug.org/options.cgi/chat-lrug.org
> List info: http://lists.lrug.org/listinfo.cgi/chat-lrug.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20160718/b8df8974/attachment-0002.html>


More information about the Chat mailing list