Skip to content

Instantly share code, notes, and snippets.

@joshwlewis
Created November 21, 2013 16:31
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshwlewis/7585033 to your computer and use it in GitHub Desktop.
Save joshwlewis/7585033 to your computer and use it in GitHub Desktop.
When using paper_trail and devise, new user versions are saved on each request. The following prevents saving new user versions when devise trackable columns (sign_in_count, current_sign_in_at, last_sign_in_at, current_sign_in_ip, last_sign_in_ip) are updated.
class User < ActiveRecord::Base
devise :trackable
has_paper_trail
def update_tracked_fields!(request)
without_versioning { super(request) }
end
end
@joshwlewis
Copy link
Author

Tested on Rails 4.0.1, Devise 3.0.3, PaperTrail 3.0.0.beta1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment