diff options
-rw-r--r-- | app/helpers/sessions_helper.rb | 8 | ||||
-rw-r--r-- | app/views/layouts/application.html.erb | 7 |
2 files changed, 13 insertions, 2 deletions
diff --git a/app/helpers/sessions_helper.rb b/app/helpers/sessions_helper.rb index 29a5c90..20010c8 100644 --- a/app/helpers/sessions_helper.rb +++ b/app/helpers/sessions_helper.rb @@ -14,10 +14,14 @@ module SessionsHelper #method creating for self.current_user def current_user=(user) - remember_token = User.hash(cookies[:remember_token]) - @current_user ||= User.find_by(remember_token: remember_token) + @current_user = user end + def current_user + remember_token = User.hash(cookies[:remember_token]) + @current_user ||= User.find_by(remember_token: remember_token) + end + # checks if someone is currently signed in def signed_in? !current_user.nil? diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 8a81c0a..469f024 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -18,9 +18,16 @@ <%= submit_tag("Go", {:class => "btn btn-warning"}) %> <% end %> </div> + <li> + <%= link_to "Sign out", signout_path, method: "delete" %> + </li> </header> </div> + <% if signed_in? %> + <li> <%= current_user.user_name %> </li> + <% end %> + <div class="container"> <%= yield %> </div> |