will_paginate with group_by

I am trying to use will_paginate with group_by but i keep getting
"undefined method `total_pages' for".

--Controller--

@records = Record.paginate( :conditions => ['this_id = ? and that_id =
?',session[:this_id],session[:that_id]], :page => params[:page],:order
=> 'created_at DESC', :per_page => 2).group_by { |c|
c.created_at.to_date }

--view--

<% @records.each do |d, records| %>
<b><%= d %></b>
  <% for r in records %>
    <p><%= link_to r.title, :action => "action", :id => r.id %></p>
  <% end %>
<% end %>
<%= will_paginate @records %>

any help is greatly appreciated.

Silly me!

Here is how I should have written it.

1. Remove the group_by from controller
2. Place it in view

--Controller--

@records = Record.paginate( :conditions => ['this_id = ? and that_id =
?',session[:this_id],session[:that_id]], :page => params[:page],:order
=> 'created_at DESC', :per_page => 2)

--view--

<% @records.group_by { |c|
c.created_at.to_date }.each do |d, records| %>
<b><%= d %></b>
  <% for r in records %>
    <p><%= link_to r.title, :action => "action", :id => r.id %></p>
  <% end %>
<% end %>
<%= will_paginate @records %>