Ibrahim MA
Ibrahim MA

Reputation: 11

How can I solve this issue for the login?

Hi Everyone I will appreciate if someone can help me with this error: I'm building a ruby on rails app using Devise Gem.

                                         --Error--

undefined method `current_sign_in_at' for #<User id: 1, email: "[email protected]", created_at: "2022-04-29 23:08:34.796522000 +0000", updated_at: "2022-04-29 23:08:34.796522000 +0000">

-------------------------------------------------------------------------------------------------
 else
        match = matched_attribute_method(method.to_s)
        match ? attribute_missing(match, *args, &block) : super
      end
    end
    ruby2_keywords(:method_missing)
-----------------------------------------------------------------------------------------------

Upvotes: 1

Views: 193

Answers (1)

Aetherys
Aetherys

Reputation: 21

Have you checked your migrations ?

To make the current_sign_in_at method available for your User model you should uncomment this line before doing your migrations. Then redo your data base (that would delete your existing data).

enter image description here

if you don't want to lose your data, you can add it via a new migration instead if needed.

execute rails generate migration AddCurrentSignInAtToUser and inside of the new file add :

  def change
    add_column :users, :current_sign_in_at, :datetime
  end

I haven't tested this last option but it should normally work.

Upvotes: 0

Related Questions