views:

742

answers:

4

I have the will_paginate plugin working in an application, but when I paginate a resource it just spits out the HTML as text, doesn't provide links to the next pages and such.

And when I manually type in the URL the plugin is working it just doesn't make <%= will_paginate @products %> into links such as next 1 2 3 ... last

This is the output

<span class="disabled prev_page">&amp;laquo; Previous</span> <span class="current">1</span> <a href="/products?page=2" rel="next">2</a> <a href="/products?page=2" class="next_page" rel="next">Next &amp;raquo;</a>

controller: def index

@products = Product.all.paginate :per_page => 5, :page => params[:page]
@product_categories = ProductCategory.find(:all)
respond_to do |format|
  format.html # index.html.erb
  format.xml  { render :xml => @products }
end

end

view

<%= will_paginate @products %> 
<%= will_paginate %> #for some reasons this works too
A: 

WILL PAGINATE MOVED TO GITHUB. This repository is no longer updated. It's recommended that you install the gem instead of a Rails plugin:

gem install will_paginate

and Try Again

Salil
I think that gem is outdated
Sam
gem 'agnostic-will_paginate', :require => 'will_paginate'
Sam
That is the fix for rails3
Sam
But that still doesn't work
Sam
please post the controller side code you write so far.
Salil
A: 

I believe the reasons is the ways rails3 escapes html and for whatever reason will_pagiante is getting escaped.

to fix this you first need to get the correct gem as the plugin won't work so add gem 'agnostic-will_paginate', :require => 'will_paginate' and that is done in the new gem file located in the app folder of a rails3 project.

After that you need to stop rails from escaping will_paginate with raw so something like <%=raw will_paginate @products %> which is the opposition of <%=h will_paginate @products %> which in rails3 is equivalent to <%= will_paginate @products %>

Sam
+1  A: 
source 'http://rubygems.org'

gem 'rails', '3.0.0.beta2'
gem "will_paginate", '3.0.pre' 

if you run into troubles related to haml we use that version:

gem 'haml', '3.0.2'
Andreas Klinger
A: 

will_paginate is now at this location:
gem 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git', :branch => "rails3"

update your gemfile

David Henner