2017-03-07 11 views
0

私が達成しようとしているのは、ユーザーがクリックするとトグルされるフォローボタンです。これはusers_helper.rbヘルパーにあります。ここに私が持っているものがあります。条件付きでユーザーのフォローボタンを表示

私は助けを必要とラインは「ELSIF CURRENT_USER!= @user」私はここで何をしようとしている

は、彼が自分自身に従うことができないので、ユーザー自身のプロファイルのフォローボタンを削除することです。

ご協力いただきありがとうございます!

def render_follow_conditionally 
    if user_signed_in? 
    follow_toggler 
    else 
    button_to "Follow", new_user_session_path, class: 'btn btn-lake' 
    end 
end 

def follow_toggler 
    if current_user.following? @user 
     button_to "Followed", unfollow_user_path(@user), class: 'btn btn-default' 
    elsif current_user != @user 
     button_to "Follow", follow_user_path(@user), class: 'btn btn-default' 
    end 
end 

答えて

1

あなたは、そのIDで感謝を私のために

elsif current_user.id != @user.id 
+0

作品ユーザーを比較する必要があります! – Joshua

関連する問題