いつもお世話になります。
https://qiita.com/Tommy1218/items/12c3392dff6da1c87fdf
上記のサイトを参考にRailsでログイン機能を実装しようとしているのですが、
NoMethodError (undefined method `encrypt' for User (call 'User.connection' to establish a connection):Class):
エラーが出てしまいます。
以下のようにapplication_controller.rb内にencryptメソッドは記述してあるのですが、NoMethodErrorになってしまう原因が解明できない状態です。
ご教示のほどお願いいたします。
Ruby
1# user.rb 2 3 def self.new_remember_token 4 SecureRandom.urlsafe_base64 5 end 6 7 def encrypt(token) 8 Digest::SHA256.hexdigest(token.to_s) 9 end 10 11 12# application_controller.rb 13 14 def current_user 15### ↓の行でエラー 16 remember_token = User.encrypt(cookies[:user_remember_token]) 17 @current_user ||= User.find_by(remember_token: remember_token) 18 end 19 20 21 22エラー内容 23NoMethodError (undefined method `encrypt' for User (call 'User.connection' to establish a connection):Class):
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。