Skip to content

Instantly share code, notes, and snippets.

@dmz006
Created August 28, 2013 02:50
Show Gist options
  • Save dmz006/6361625 to your computer and use it in GitHub Desktop.
Save dmz006/6361625 to your computer and use it in GitHub Desktop.
skip_trackable if javascript
class CatalogController < ApplicationController
prepend_before_action :skip_trackable, :only => [:index]
before_filter :authenticate_user!, :except => [:show, :index]
def skip_trackable
request.env['devise.skip_trackable'] = true if request.env["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest"
end
However I still see in my log:
(0.3ms) UPDATE `users` SET `last_activity_at` = '2013-08-28 02:48:26', `updated_at` = '2013-08-28 02:48:26' WHERE `users`.`id` = 1
based details on: http://stackoverflow.com/questions/17791626/devise-make-a-request-without-resetting-the-countdown-until-a-user-is-logged-o
because of:
unless warden.request.env['devise.skip_trackable']
warden.session(scope)['last_request_at'] = Time.now.utc
end
I do not know if the before_filters occur before the warden call but it appears they don't which is why the post refers to prepend_before_action; which i've not researched well enough yet to know the difference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment