ankane/blind_index

`rotate: true` does not work.

hiroki-uchida opened this issue · 2 comments

I tried to upgrade from 0.3.5 to 1.0.1 according to README.md.

This part of README.md does not work.

class User < ApplicationRecord
  blind_index :email, key: ENV["USER_EMAIL_BLIND_INDEX_KEY"], legacy: true, rotate: true
end

The error is as follows.

NoMethodError: undefined method `merge' for true:TrueClass
from /usr/local/bundle/gems/blind_index-1.0.1/lib/blind_index/model.rb:5:in `block in blind_index'

I think merge does not work, because true goes into the variable rotate.

indexes.concat(attributes.map { |a| [a, rotate.merge(rotate: true)] }) if rotate

      indexes.concat(attributes.map { |a| [a, rotate.merge(rotate: true)] }) if rotate
                                              ^^^^^^^^^^^^

rotate: {slow: true} works, but I don't want it.
I tried rotate: {slow: false} but it also does not work.


environment.

/app # ruby --version
ruby 2.6.4p104 (2019-08-28 revision 67798) [x86_64-linux-musl]
/app # gem --version
3.0.3
/app # bundler --version
Bundler version 2.0.2
/app # rails --version
Rails 6.0.0
/app # gem list | grep blind_index
blind_index (1.0.1, 0.3.5)
/app # cat /etc/issue 
Welcome to Alpine Linux 3.10
Kernel \r on an \m (\l)

Hey @hiroki-uchida, thanks for reporting. Fixed on master. You should be able to use rotate: {} in the meantime. rotate: {slow: false} should also work - what problem are you seeing with that?

Edit: On 2nd thought, rotate: true isn't really needed except for upgrading, so just updated the instructions to use rotate: {} instead.

I think it's a very good decision.

Perhaps rotate: {slow: false} was my misunderstanding.
I will report again if I find a problem in detail.

Thank you very much.