ruby on rails 4 - Creating a mutual friends list -
ruby on rails 4 - Creating a mutual friends list -
i've been through treebook tutorial on treehouse , i've been trying enhance it.
i want add together list of mutual friends on profile_page shows friends have in mutual user.
i can write if statement show profile_name of mutual users.
e.g.
<% if current_user.friends.include?(friend) , @user.friends.include?(friend) %> <%= friend.profile_name %> <% end %>
but i'd write block go through , show other information. how create query in profiles controller can utilize in block?
so want like:
def common_friends friends.where(friends: [friend1, friend2]) end
this way querying friends friend list includes both friend1 , friend2.
ruby-on-rails-4
Comments
Post a Comment