Skip to content

Instantly share code, notes, and snippets.

@joshwlewis
Created November 21, 2013 16:31
Show Gist options
  • Select an option

  • Save joshwlewis/7585033 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
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