lib/hashid/rails.rb in hashid-rails-1.1.0 vs lib/hashid/rails.rb in hashid-rails-1.1.1
- old
+ new
@@ -32,9 +32,19 @@
self.class.encode_id(id)
end
alias to_param hashid
module ClassMethods
+ def relation
+ super.tap { |r| r.extend ClassMethods }
+ end
+
+ def has_many(*args, &block) # rubocop:disable Style/PredicateName
+ options = args.extract_options!
+ options[:extend] = Array(options[:extend]).push(ClassMethods)
+ super(*args, options, &block)
+ end
+
def encode_id(ids)
if ids.is_a?(Array)
ids.map { |id| hashid_encode(id) }
else
hashid_encode(ids)