From 9ea325628e439614b31fb75c9ce2580181b30b56 Mon Sep 17 00:00:00 2001 From: "Mark J. Titorenko" Date: Fri, 1 Mar 2013 12:17:42 +0000 Subject: [PATCH] Fix search facility by setting current-user; factored current_user_data commonality into ApplicationHelper. --- app/helpers/application_helper.rb | 11 +++++++++++ app/views/main/index.html.erb | 12 +----------- app/views/main/search.html.erb | 2 ++ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be794..8d07f844 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,13 @@ module ApplicationHelper + def current_user_data + current_user_data = { + :id => current_user.id, + :first_name => current_user.first_name, + :last_name => current_user.last_name, + :email => current_user.email, + :username => current_user.username, + :auth_token => current_user.authentication_token, + :gravatar_hash => current_user.gravatar_hash + } + end end diff --git a/app/views/main/index.html.erb b/app/views/main/index.html.erb index b500042f..6428e4ae 100644 --- a/app/views/main/index.html.erb +++ b/app/views/main/index.html.erb @@ -10,16 +10,6 @@ <%= javascript_tag do %> <%- if user_signed_in? %> - <%- current_user_data = { - :id => current_user.id, - :first_name => current_user.first_name, - :last_name => current_user.last_name, - :email => current_user.email, - :username => current_user.username, - :auth_token => current_user.authentication_token, - :gravatar_hash => current_user.gravatar_hash - } - %> $.data(document, "current-user", <%= current_user_data.to_json.html_safe %>); <%- end %> $(document).data("active-users", []) @@ -63,4 +53,4 @@ window._cloudfuji_help = <%= cloudfuji_help_vars.to_json.html_safe %>; <%- end %> -<%- end %> \ No newline at end of file +<%- end %> diff --git a/app/views/main/search.html.erb b/app/views/main/search.html.erb index 355ce5c2..dda24c63 100644 --- a/app/views/main/search.html.erb +++ b/app/views/main/search.html.erb @@ -1,4 +1,6 @@ <%= javascript_tag do %> + $.data(document, "current-user", <%= current_user_data.to_json.html_safe %>); + $(document).ready(function(){ Kandan.Plugins.initAll() activities = <%= @activities.to_json(:include => :user).html_safe %>;