Using will paginate


#1

Hello.
I am trying to use the will_paginate plugin and I like it very much.

I have read an entry in this forum
http://www.ruby-forum.com/topic/109036, about making will_paginate an
acts_as taggable playing together and
that make me think it will be easy to paginate on a query moved to the
model,
like it was suggested from Jamis B.s in a known article “Skinny
controller, Fat Mode”.

I have defined a query method in the model

class Thing
def self.find_special_list
find(:all, :conditions => …)
end
alias find_all_special_list find_especial_list
end

I pretend paginate with this
@things = Thing.paginate_special_list and I have a strange error saying
that find_special_list is not defined or something like that.

Anybody has tried this?. Is possible to paginate a collection queried
with a class method?

Thanks


#2

just to be sure:
alias find_all_special_list find_especial_list

should not be
alias find_all_special_list find_special_list

and
def self.find_special_list

is really a class method ?

marcel

On 26 Mai, 17:26, Juanma C. removed_email_address@domain.invalid


#3

You 're right
it should be find_all_special_list find_special_list
and I pretend that find_special_list be a class method (a custom finder
method)
Maybe the alias methods can not be used with class methods, can it?

lanzm wrote:

just to be sure:
alias find_all_special_list find_especial_list

should not be
alias find_all_special_list find_special_list

and
def self.find_special_list

is really a class method ?

marcel

On 26 Mai, 17:26, Juanma C. removed_email_address@domain.invalid


#4

Thank you very much Chris


#5

Well, I think I go to nowhere with this idea.
I tried to move the query I am paginating from the controller to the
model.
I want to have my controllers as skinny as possible.
But, obviously I don´t want to move the paginate method to the model,
nor fight with pages, offsets and limits in the query, only I wan to use
a finder defined there.

Anythody thinks this is something possible with pagination?
How?


#6

On 5/28/07, Juanma C. removed_email_address@domain.invalid wrote:

You 're right
it should be find_all_special_list find_special_list
and I pretend that find_special_list be a class method (a custom finder
method)
Maybe the alias methods can not be used with class methods, can it?

class Whatever < ActiveRecord::Base
class << self
alias_method :target, :source
end
end

or

http://pastie.caboo.se/66108


Chris W.
http://errfree.com // http://errtheblog.com