Q:

will_paginate with load more button in Rails 3.1 using jQuery

I've read that others have followed the Endless Page railscast and modified it to use a load more button.  However, when I tried to modify it, I just end up appending the same productions.  In other words, it's still pulling from the current_page. 
When I click my "load more" div, I upload trigger this:
$("#products").append("<%= escape_javascript render( @products) %>");

In my controller, I have
@products = Product.where(:created_at => 180.days.ago..Time.now).order(sort_column + " " + sort_direction).page(params[:page]).per_page(16)

I'm wondering if I should be able to somehow use will_paginate's .next_page.  
Has anyone done something similar with will_paginate using Rails 3 and jQuery? 

A:

Try something like this
In products view
# Show link only if there are more than one page and pass page and sorting parameters
<% unless @products.total_pages < 2 %>
    <%= link_to 'show_more', method_that_returns_products_path(:sort => sort_column, :direction => sort_direction, :page => 2), :remote => true, :id => 'show_more_link' %>
<% end %>

and in js response
$("#products").append("<%= escape_javascript render( @products) %>");

// Hide link if it is last page otherwise update link
<% if @products.total_pages == @products.current_page %>
    $("#show_more_link").hide();
<% else %>
    $("#show_more_link").attr("href", "<%= method_that_returns_products_path(:sort => sort_column, :direction => sort_direction, :page => (@products.current_page + 1)) %>");
<% end %>

