Skip to content

Commit

Permalink
Fix search facility by setting current-user; factored current_user_da…
Browse files Browse the repository at this point in the history
…ta commonality into ApplicationHelper.
  • Loading branch information
mjtko committed Mar 1, 2013
1 parent b9c39e9 commit 9ea3256
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
11 changes: 11 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 1 addition & 11 deletions app/views/main/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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", [])
Expand Down Expand Up @@ -63,4 +53,4 @@

window._cloudfuji_help = <%= cloudfuji_help_vars.to_json.html_safe %>;
<%- end %>
<%- end %>
<%- end %>
2 changes: 2 additions & 0 deletions app/views/main/search.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>;
Expand Down

0 comments on commit 9ea3256

Please sign in to comment.