Try:
def correct_user
if current_user
@user = User.find(current_user.id)
unless (@user && current_user.id == @user.id) || ((current_user.access_id==@user.id)&&(current_user.id==@user.access_id))
redirect_to root_path
end
else
redirect_to root_path
end
end
Actually, there is no params[:id]
like thing here. The current_user
is the user whom you are checking so you can directly find with current_user.id
as above. Replace the code with above and rectify for possible best if you find other. It is just an idea for implementation.