I am having a weird problem. I have friendship system in the site and I am trying to find out common friends. And to do that, I used intersection but it outputs in view, which doesn't make sense at all.
I have this in my helper.
def display_connections_buttons(friend_id)
if(@profile.id == current_user.id) || (@profile.username == current_user.username)
else
common_friends = @profile.friends & current_user.friends
common_friends.each do |friend|
if friend.id == friend_id
render 'profiles/connections_buttons'
end
end
end
end
According to common friends, I am planning to render buttons. But I am getting this output on the screen:
#<User id: 9, first_name: "REMOVED", last_name: "REMOVED", email: "REMOVED", password_digest: "$2a$10$xkaCxStsc70BYpJN9yulQOuDyXOBJEIEaW817YDst9t...", authorization_token: "REMOVED", username: "", school: "REMOVED", program: nil, information: nil, website: nil, courses: nil, groups: nil, picture_id: nil, created_at: "2015-09-24 19:51:52", updated_at: "2015-09-24 19:51:52">]
I replaced some of the data with 'REMOVED'. I don't want it to appear.
I removed some of the code to understand where output comes from, and when I remove 'common_friends = @profile.friends & current_user.friends' output disappears from screen. Why do you think this piece of code outputs that?
Thank you.
View File
<span class="list-group-item title">Connections</span>
<div class="connections clearfix">
<% @profile.friends.each do |friend| %>
<div class="connection pull-left">
<div class="content pull-left">
<div class="connection-thumbnail pull-left">
<%= image_tag friend.picture_id.blank? ? 'default.png' : friend.picture_id, :class => 'frame' %>
</div>
<div class="connection-name">
<%= link_to friend.first_name + ' ' + friend.last_name, profile_path(friend.id) %>
</div>
<div class="connection-information">
<div class="information"><%= friend.website %></div>
<div class="information"><%= friend.colour %></div>
</div>
</div>
<div class="connection-dropdown">
<%= display_connections_buttons(friend.id) %>
</div>
</div>
<% end %>
</div>
After I tried @Swards way, I am getting output of render as text. Not the variables.
<div class="dropdown pull-right"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> Options <span class="caret"></span> </button> <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> <li><a href="#">Send Message</a></li> <li role="separator" class="divider"></li> <li><a href="#">Disconnect</a></li> </ul> </div>