[LRUG] Rails log_tags in production
Jon Wood
jon at ninjagiraffes.co.uk
Mon Jul 18 02:21:40 PDT 2016
My gut feel is that Pingdom is probably not sending any session cookies, so
session_data will be returning nil.
On Mon, 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/0e4fba31/attachment-0002.html>
More information about the Chat
mailing list