Last active
August 29, 2015 14:04
-
-
Save yorzi/34ddf5d02cbf01137a92 to your computer and use it in GitHub Desktop.
paper_trail_history.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PaperTrailHistory < PaperTrail::Version | |
def self.compose_query(params) | |
condition = "" | |
condition << | |
(params[:type].present? ? "whodunnit NOT IN (?)" : "whodunnit IN (?)") | |
condition << " AND object_changes ILIKE '%#{params[:q]}%'" if params[:q].present? | |
condition | |
end | |
def self.find_history(params) | |
condition = PaperTrailHistory.compose_query(params) | |
PaperTrailHistory.where(condition, User.admin_ids).order('created_at DESC').page(params[:page]) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment