I am getting array of records from sql query now I want to find whether current users record is present in that array of records and at which position. So I wrote following query but it is returning null.
@top_score_cards = Score.group(:points).distinct.order("points DESC, updated_at DESC").where("points != ? And activity_id= ?",0,params[:@myActivity])#.limit(3)
@current_users_rank=@top_score_cards.index(current_user)
puts @current_users_rank
You could try:
top_score_cards.include?(current_user.id)
you can use pluck to directly convert a database result into an array.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments