Application Controller Flashcards

1
Q

(APP) def current_user

A

@current_user ||= User.find_by(session_token: session[:session_token])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

(APP) def ensure_logged_in!

A

redirect_to new_session_url unless logged_in?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

(APP) def log_in!

A
def log_in!(user)
session_token = user.reset_session_token!
@current_user = user
end
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

(APP) def log_out!

A

current_user.reset_session_token!
session[:session_token] = nil
@current_user = nil

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

(APP) def logged_in?

A

!!current_user

How well did you know this?
1
Not at all
2
3
4
5
Perfectly