6
にマッチしていない私はdevise_token_auth
バージョン0.1.38
を使用して、既存のユーザーに署名しようとしているが、私は、ライブラリのsessions_controller
でIndexError: string not matched
を打っています。devise_token_auth&Railsの5 - はIndexError:文字列が
IndexError (string not matched):
devise_token_auth (0.1.38) app/controllers/devise_token_auth/sessions_controller.rb:37:in `[]='
devise_token_auth (0.1.38) app/controllers/devise_token_auth/sessions_controller.rb:37:in `create'
actionpack (5.0.0) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.0.0) lib/abstract_controller/base.rb:188:in `process_action'
actionpack (5.0.0) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.0.0) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
sessions_controller
から関連するコードは次のとおりです。
if @resource and valid_params?(field, q_value) and @resource.valid_password?(resource_params[:password]) and ([email protected]_to?(:active_for_authentication?) or @resource.active_for_authentication?)
# create client id
@client_id = SecureRandom.urlsafe_base64(nil, false)
@token = SecureRandom.urlsafe_base64(nil, false)
# !! Next line is line 37 with the error !!
@resource.tokens[@client_id] = {
token: BCrypt::Password.create(@token),
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
}
@resource.save
sign_in(:user, @resource, store: false, bypass: false)
それは私がtokens
列に不正なデータを作成している可能性が高いですので、私は既存のプロジェクトにdevise_token_auth
を追加しました。私はのコードを模倣することを含め、私の既存のユーザーにtoken
jsonをデフォルト設定するさまざまな方法を試しました。
add_column :users, :tokens, :json, null: false, default: {}
User.reset_column_information
client_id = SecureRandom.urlsafe_base64(nil, false)
token = SecureRandom.urlsafe_base64(nil, false)
User.find_each do |user|
user.uid = user.email
user.provider = 'email'
user.tokens[client_id] = {
token: BCrypt::Password.create(token),
expiry: (Time.now + DeviseTokenAuth.token_lifespan).to_i
}
user.save!
end
これについては、issue #101に記載されていますが、具体的な解決策はありませんでした。私がどこに間違っているのか?
私にとって、これは私がHeroku上で私のレールアプリを実行するときに起こるようです。ローカルインスタンスにはこの問題はありません。 Postgresのバージョン(9.6.2)がHerokuのバージョン(9.6.4)とローカルに異なることに気付きました。それが問題を引き起こしているかどうかわからない –