1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

RailsでTypeError can't quote Rack::Session::SessionIdが起きる場合の解決策

Posted at

session.idをそのまま使ってクエリを実行すると、TypeError can't quote Rack::Session::SessionIdが起きる。

# Bad
user = User.find_by(session_id: session.id)
# => TypeError can't quote Rack::Session::SessionId

# Good
user = User.find_by(session_id: session.id.to_s)
# Success!

上記のコードはRails 5.2.4.2で実行している。認証情報を扱うgemでこの例外が起きることもあるので、Railsのバージョンによってsession.idの実装が異なるのかもしれない。

参考リンク

ruby on rails - TypeError - can't quote Rack::Session::SessionId - Stack Overflow

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?