Paginate with Rails 2.0.2 question

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

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

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:inevaluate_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:insilence_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:inload’
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:inload_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:inrequire’
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. [email protected]

Why don’t you use will_paginate plugin.

will_peginate is cool. but if you are converting ur app to rails 2.x
you may need to look classic_pegination.

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

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

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.

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 :slight_smile:

Fred

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

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. :slight_smile:

-Kyle

On Apr 9, 1:24 am, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs