Skip to content

Commit 9ea3256

Browse files
committed
Fix search facility by setting current-user; factored current_user_data commonality into ApplicationHelper.
1 parent b9c39e9 commit 9ea3256

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

app/helpers/application_helper.rb

+11
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
11
module ApplicationHelper
2+
def current_user_data
3+
current_user_data = {
4+
:id => current_user.id,
5+
:first_name => current_user.first_name,
6+
:last_name => current_user.last_name,
7+
:email => current_user.email,
8+
:username => current_user.username,
9+
:auth_token => current_user.authentication_token,
10+
:gravatar_hash => current_user.gravatar_hash
11+
}
12+
end
213
end

app/views/main/index.html.erb

+1-11
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010

1111
<%= javascript_tag do %>
1212
<%- if user_signed_in? %>
13-
<%- current_user_data = {
14-
:id => current_user.id,
15-
:first_name => current_user.first_name,
16-
:last_name => current_user.last_name,
17-
:email => current_user.email,
18-
:username => current_user.username,
19-
:auth_token => current_user.authentication_token,
20-
:gravatar_hash => current_user.gravatar_hash
21-
}
22-
%>
2313
$.data(document, "current-user", <%= current_user_data.to_json.html_safe %>);
2414
<%- end %>
2515
$(document).data("active-users", [])
@@ -63,4 +53,4 @@
6353

6454
window._cloudfuji_help = <%= cloudfuji_help_vars.to_json.html_safe %>;
6555
<%- end %>
66-
<%- end %>
56+
<%- end %>

app/views/main/search.html.erb

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<%= javascript_tag do %>
2+
$.data(document, "current-user", <%= current_user_data.to_json.html_safe %>);
3+
24
$(document).ready(function(){
35
Kandan.Plugins.initAll()
46
activities = <%= @activities.to_json(:include => :user).html_safe %>;

0 commit comments

Comments
 (0)