Home > database >  How can I solve this issue for the login?
How can I solve this issue for the login?

Time:05-02

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)
-----------------------------------------------------------------------------------------------

CodePudding user response:

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.

CodePudding user response:

Thank you so much everyone for your help, appreciate that. NOW it's working and what I did

  1. Uncomment the trackable in the migration file
  2. Then I replaced the method delete with get in the "devise.rb" like this: config.sign_out_via = :get

Instead of

config.sign_out_via = :delete --> This is not working because the client is sending (get method) and the server is expecting (delete method)

  • Related