Question: I'm having a weird problem with Kaminari, AJAX pagination and the latest rails.

I see everything is working perfectly underneath, it's doing the right calls, generating the right HTML and JS, but for reasons I don't understand it doesn't update the page after a pagination AJAX call.

The js it produces can be cut&pasted in Chrome JS console and it works perfectly(???)

My controller

```
def show
  @facility = Facility.friendly.find(params[:id]).decorate
  @pets = @facility.pets.page(params[:page]).per(1)
  respond_to do |format|
    format.html
    format.js do
      render 'pets/pets', layout: false
    end
  end
end

```

pets/pets.js.haml

```
:javascript
  $('#pets').html("#{escape_javascript(render(partial: 'pets/pets', locals: {pets: @pets}))}");

```

pets/\_pets.html.haml

```
#pets
  .row.products
    = render pets

= paginate pets, remote: true

```

What can be the reason for not updating the page? The js appears to be correct but it doesn't sort any effect if it comes from Rails, only if I paste it on the console (the same exact JS, pasted from the debug console)

If someone can help me, I'm literally going nuts, and I want to solve this at least as much as I know that the problem will 99% be my fault and after I will like hang myself :)

TIA - ngw

Answer: 
Ok the first part collecting the data it would work for the exercise. 

What you would need to tweek is the logic to find the winner. I will start after you collect the times for each of the teams. 

What I would suggest to do is:

1. Iterate from 0..N-1 (N = 8 which is the array length) (I didn't saw that loop in your code, I hope I am not missing it)
2. While iterating do the comparison as following:

```
int chevyWins = 0, fordWins = 0;
for (int i = 0; i < 8; i++)
{
    if (chevy[i] < ford[i])
    {
        //Note the difference with your code, your are doing 
        //the subtraction chevy[i] - ford[i] that will give you negative numbers.
        chevyWins++;
        Console.WriteLine(String.Format("Chevy won by {0}", (ford[i] - chevy[i])));
    }
    else if (chevy[i] > ford[i])
    {
        fordWins++;
        Console.WriteLine(String.Format("Ford won by {0}", (chevy[i] - ford[i])));
    }
    else
    {
        Console.WriteLine("Tie!");
    }
}

if (chevyWins > fordWins)
{
    Console.WriteLine("Chevy Wins the competition!");
}
else if (chevyWins < fordWins)
{
    Console.WriteLine("Ford Wins the competition!");
}
else
{
    Console.WriteLine("The competition was tie!");
}

```

I think the issue with your code was that you were not iterating to compare each of the scenarios. And the second was how you were calculating the difference between each competition.

[Here](https://dotnetfiddle.net/26fbEC) is the fiddle.

I hope this works for you!
Regards.
This is done in LinqPad so you would take out the ".Dump()" but you can use .Zip to do what you are trying to do by comparing both arrays. I have shortened the code for example purpose but you would do your loops and push the items into the arrays then .Zip them to do your comparison. 

```
using System.Linq;

void Main()
{
    double[] chevy = { 1, 2, 1, 1 };
    double[] ford = { 2, 1, 1, 2 };

    var results = chevy.Zip(ford, (c, f) => 
    {
        if(c < f)
        {
            return "Chevy Won";
        }
        else if(f < c)
        {
            return "Ford Won";
        }
        else
        {
            return "It was a tie";
        }
    });

    results.Dump();
}

//output
    Chevy Won 
    Ford Won 
    It was a tie 
    Chevy Won 

```