if statement - Rails unless with 2 conditions, second condition not working using slim -
here's code:
- unless relationship.are_friends?(current_user, @user) && (current_user != @user) - puts "d"*100 - puts "#{current_user.inspect}" - puts "#{@user.inspect}" = link_to "add friend", controller: "relationships", action: "req", name: @user.name, remote: true, class: "friend_link"
basically second condition "current_user != @user" not working , don't know why. when puts current user , @user working correctly. @user = user.find_by_name(params[:name]).
thanks help!
i assume requirement. allow add b friend if:
- a , b not friends and
- a , b not same person
so, in pseudo-code, unless (already_friends or same_person) allow_add_friend end
if requirement, statement should read:
unless relationship.are_friends?(current_user, @user) or (current_user == @user)
note &&
changed or
, !=
changed ==
.
Comments
Post a Comment