Railscastエピソード 275 - How I testでは、次のコードを使用してパスワードのリセットをユーザーに送信します。
def send_password_reset
generate_token(:password_reset_token)
....
... etc
end
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
私の質問はコードの最後から 2 番目の行に関するものです。end while User.exists?(column => self[column])
これはそのままでは正常に動作しますが、ハッシュロケットを交換するとスペックが失敗します。end while User.exists?(column: self[column])
Failure/Error: user.send_password_reset
ActiveRecord::StatementInvalid:
SQLite3::SQLException: no such column: users.column: SELECT 1 FROM "users" WHERE "users"."column" = 'Y7JJV4VAKBbf77zKFVH7RQ' LIMIT 1
なぜこうなった?ハッシュロケットを使用しなければならない状況はありますか?これに関するガイドラインはありますか?