# Paginate with Rails 2.0.2 question

**URL:** <https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383>\
**Category:** Rails\
**Created:** [March 31, 2008, 4:52am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383 "2008-03-31T04:52:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 4:52am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/1 "2008-03-31T04:52:44Z")

</div>

Hi,

So I’m using @post\_pages, @posts = paginate :posts, :per\_page =\> 10  
to paginate.

But I have rails 2.0.2 on my VPS. Now this version of paginate throws  
an error. What happened to classic pagination and what is done now?

Thanks,

Ron

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 4:57am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/2 "2008-03-31T04:57:20Z")

</div>

Ron wrote:

> Hi,
> 
> So I’m using @post\_pages, @posts = paginate :posts, :per\_page =\> 10  
> to paginate.
> 
> But I have rails 2.0.2 on my VPS. Now this version of paginate throws  
> an error. What happened to classic pagination and what is done now?

Became a plugin called: classic\_pagination

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 5:20am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/3 "2008-03-31T05:20:51Z")

</div>

Hi James,

Thanks…but I tried that. I did:  
sudo ruby plugin install svn://errtheblog.com/svn/plugins/

Now I’m getting:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active\_support/  
dependencies.rb:478:in `const_missing': uninitialized constant Rails::Plugin::Err (NameError) from /home/ron/ic/vendor/plugins/plugins/acts_as_cached/init.rb:2:in `evaluate\_init\_rb’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:  
79:in `evaluate_init_rb' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/core_ext/kernel/reporting.rb:11:in `silence\_warnings’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb:  
75:in `evaluate_init_rb' from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin.rb: 39:in `load’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin/  
loader.rb:33:in `load_plugins' from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails/plugin/ loader.rb:32:in `load\_plugins’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:  
189:in `load_plugins' ... 22 levels... from /usr/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/ active_support/dependencies.rb:496:in `require’  
from /usr/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:  
39  
from /usr/local/lib/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require’  
from script/server:3

Now that I look at it, maybe I didn’t specify the whole path. It  
seems to have installed 3 or 4 plugins. Not sure how I would  
uninstall them and just install the classic\_pagination plugin. One of  
them must be incompatible with 2.0.2

Ron

On Mar 30, 7:57 pm, James B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 6:44am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/4 "2008-03-31T06:44:45Z")

</div>

Why don’t you use will\_paginate plugin.

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 1:37pm UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/5 "2008-03-31T13:37:13Z")

</div>

will\_peginate is cool. but if you are converting ur app to rails 2.x  
you may need to look classic\_pegination.

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 2:08pm UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/6 "2008-03-31T14:08:15Z")

</div>

I found that converting to will\_paginate to be so easy it confused  
me. I was looking for more work to do and didn’t realize I was done.  
There’s a railscast on it somewhere.

F

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [March 31, 2008, 4:29pm UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/7 "2008-03-31T16:29:29Z")

</div>

will\_paginate rocks. As for removing the plugin, just remove the  
plugin from the vendor/plugins directory. That should do the trick.  
I’ve used both and they work well.

Serge

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [April 9, 2008, 1:50am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/8 "2008-04-09T01:50:49Z")

</div>

I have, I think, gotten the gem. The files “will\_paginate” and  
“will\_paginate.rb” exist in my vendor/plugins/will\_paginate  
directory. I still get the “undefined method ‘paginate’” message when  
I try to load the page that’s supposed to use it. Another posting  
somewhere else said I needed to add “require ‘will\_paginate’” to my  
environment.rb, and I did that, with no change in the result. I’m not  
sure if it should be necessary, but I am restarting the server every  
time I make a change.

All I’m really trying to do is use AWDWR to learn about Rails, and I  
wasn’t bright enough to install the downrev Rails (the previous layer  
of the onion was “scaffold”). If uninstalling 2.0.2, and installing  
1.something (what a pain) really is the only way to use AWDWR, I guess  
I can, but this makes the whole business look pretty fragile, which I  
thought was one of the main things RoR was _not_ supposed to be.

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [April 9, 2008, 8:25am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/9 "2008-04-09T08:25:08Z")

</div>

On 9 Apr 2008, at 00:49, Fingal wrote:

> I have, I think, gotten the gem. The files “will\_paginate” and  
> “will\_paginate.rb” exist in my vendor/plugins/will\_paginate  
> directory. I still get the “undefined method ‘paginate’” message when  
> I try to load the page that’s supposed to use it. Another posting  
> somewhere else said I needed to add “require ‘will\_paginate’” to my  
> environment.rb, and I did that, with no change in the result. I’m not  
> sure if it should be necessary, but I am restarting the server every  
> time I make a change.

will\_paginate is great but is not a drop-in replacement for what was  
in rails 1.2 (classic\_pagination does that)

> All I’m really trying to do is use AWDWR to learn about Rails, and I  
> wasn’t bright enough to install the downrev Rails (the previous layer  
> of the onion was “scaffold”). If uninstalling 2.0.2, and installing  
> 1.something (what a pain) really is the only way to use AWDWR, I guess  
> I can, but this makes the whole business look pretty fragile, which I  
> thought was one of the main things RoR was _not_ supposed to be.

Trying to follow instructions written for a previous version of a  
framework/application is never going to be fun 🙂

Fred

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [April 9, 2008, 6:54am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/10 "2008-04-09T06:54:14Z")

</div>

Another vote for will\_paginate…

get\_order and get\_filter are application helpers in my app, and I keep a  
short list of user preferences (like their current filter, and current  
sort preferences) in the session…

def index  
order = get\_order(‘projectview’, ‘proj\_name’)  
cond = get\_filter(‘project’, ‘scenario’)

```
# retrieve the data
@projectviews = Projectview.paginate :page => params[:page], 

```

:per\_page =\> session[:userpref].page\_len, :order =\> order, :conditions  
=\> cond

```
respond_to do |format|
  format.html
  format.xml { render :xml => @projectviews }
end

```

end

---

<div class="post-metadata">

**Author:** ![ron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/ecae2f/32.png) [@ron](https://www.ruby-forum.com/u/ron)\
**Post date:** [April 10, 2008, 3:44am UTC](https://www.ruby-forum.com/t/paginate-with-rails-2-0-2-question/133383/11 "2008-04-10T03:44:40Z")

</div>

If you’re just wanting to follow AWDWR, just don’t use any  
pagination. You only add 4 items…

Instead of @post\_pages, @posts = paginate :posts, :per\_page =\> 10,  
just do @posts = Post.find(:all)

If you need pagination, learn will\_paginate (it works almost exactly  
like ‘find’). If you’re just getting your feet wet, focus on more  
important things. You can paginate when you have stuff that’s worth  
paginating. 🙂

-Kyle

On Apr 9, 1:24 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
