Added logout button

Added logged_in helper to allow us to check whether a user is logged in
to show the appropriate button
This commit is contained in:
Yannick 2020-04-07 20:52:45 +02:00
parent 7e4280d451
commit ab81cf9d5c
2 changed files with 5 additions and 0 deletions

View File

@ -1,4 +1,5 @@
class ApplicationController < ActionController::Base
helper_method :current_user, :logged_in?
def require_login
redirect_to login_url unless current_user.present?

View File

@ -33,7 +33,11 @@
<div class="navbar-end">
<div class="navbar-item">
<div class="buttons">
<% if !logged_in? -%>
<%= link_to "Login", login_url, { :class => "button is-primary"} %>
<% else -%>
<%= link_to "Logout", logout_url, { :class => "button is-light"} %>
<% end -%>
</div>
</div>
</div>