Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # frozen_string_literal: true
- #
- # Devise & ActsAsTaggableOn gems combination
- # This fix redefine inspect method by excluding tag_lists form it.
- #
- # Because the way Devise redefines inspect method tag_lists are getting
- # loaded on every user query.
- #
- # From Devise:
- #
- # Redefine serializable_hash in models for more secure defaults.
- # By default, it removes from the serializable model all attributes that
- # are *not* accessible. You can remove this default by using :force_except
- # and passing a new list of attributes you want to exempt. All attributes
- # given to :except will simply add names to exempt to Devise internal list.
- #
- # Redefine inspect using serializable_hash, to ensure we don't accidentally
- # leak passwords into exceptions.
- #
- module DeviseTagsFix
- def inspect
- inspection = serializable_hash(except: tag_lists).collect do |k, v|
- "#{k}: #{respond_to?(:attribute_for_inspect) ? attribute_for_inspect(k) : v.inspect}"
- end
- "#<#{self.class} #{inspection.join(', ')}>"
- end
- def tag_lists
- self.class.tag_types.map { |type| "#{type.to_s.singularize}_list" }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement