Come up with a catchy remember nothing

I am using Devise for a Rails 3.2 application and want the system to remember the user.

/app/models/user.rb:

class User < ActiveRecord::Base devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable attr_accessible :name, :email, :password, :password_confirmation, :remember_me end 

/db/schema.rb:

 create_table "users", :force => true do |t| t.string "name" t.string "email" t.string "password" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false t.string "encrypted_password", :default => "", :null => false t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" t.integer "sign_in_count", :default => 0 t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" t.string "current_sign_in_ip" t.string "last_sign_in_ip" end 

I would like to do this in the most standard / default way, and given the lack of documentation, I assume that it β€œjust works” for some people and just doesn't work for me. For example, I used the Devise generator to create migration for the user and did not redefine any controllers. I check the box, but when I check it, the user information is not remembered.

What am I missing? Is there something missing in my circuit that the generator was supposed to create?

+6
source share
2 answers

try playing with

 current_user.remember_me = true current_user.remember_me = false 

your schema.rb looks right.

0
source

I'm not sure if this is what you had in mind -

According to Module: Devise :: Models :: Rememberable devise :rememberable used to save the credentials of the user who is currently. This means that it will remember the credentials if you close the browser and do not log out.

However, when you log out, this will not save your credentials (email address, password).

0
source

Source: https://habr.com/ru/post/910046/


All Articles