Commit df10c5e

mo khan <mo@mokhan.ca>
2016-04-30 03:46:56
expose current_user as helper.
1 parent e1abd54
Changed files (2)
app/controllers/application_controller.rb
@@ -4,6 +4,7 @@ class ApplicationController < ActionController::Base
   protect_from_forgery with: :exception
   before_action :authenticate!
   rescue_from ActiveRecord::RecordNotFound, with: :record_not_found
+  helper_method :current_user
 
   protected
 
app/views/layouts/application.html.erb
@@ -62,11 +62,11 @@
                   <li><a href="#">Main Item 2</a></li>
                   <li class="divider"></li>
                   <li class="has-dropdown">
-                    <a href="#"><%= gravatar_for(@current_user, size: 16) %> <%= @current_user.username %></a>
+                    <a href="#"><%= gravatar_for(current_user, size: 16) %> <%= current_user.username %></a>
                     <ul class="dropdown">
                       <li><%= link_to t("nav.user.training_sessions"), training_sessions_path %></li>
-                      <li><%= link_to t("nav.user.profile_edit"), edit_profile_path(@current_user) %></li>
-                      <li><%= link_to t("nav.user.profile_view"), profile_path(@current_user) %></li>
+                      <li><%= link_to t("nav.user.profile_edit"), edit_profile_path(current_user) %></li>
+                      <li><%= link_to t("nav.user.profile_view"), profile_path(current_user) %></li>
                       <li class="divider"></li>
                       <li><%= link_to t("nav.user.log_out"), session_path('me'), method: :delete %></li>
                     </ul>