How do these methods work?
current_user method determines whether a user is logged in or logged out. It does this by checking whether there's a user in the database with a given session id. If there is, this means the user is logged in and
@current_user will store that user; otherwise the user is logged out and
@current_user will be
- The line
helper_method :current_user makes
current_user method available in the views. By default, all methods defined in Application Controller are already available in the controllers.
require_user method uses the
current_user method to redirect logged out users to the login page.
Here's more on the ||= syntax.
Here's more on the