Forum: Ruby on Rails Using will paginate

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2007-05-26 17:26
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 Bucks 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
15eb647956921a6bc9655c3513feb139?d=identicon&s=25 lanzm (Guest)
on 2007-05-28 13:29
(Received via mailing list)
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 Cervera <rails-mailing-l...@andreas-s.net>
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2007-05-29 04:54
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 Cervera <rails-mailing-l...@andreas-s.net>
B8dbb1987e8e5318584865f880036796?d=identicon&s=25 Chris Wanstrath (defunkt)
on 2007-05-30 18:09
(Received via mailing list)
On 5/28/07, Juanma Cervera <rails-mailing-list@andreas-s.net> 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 Wanstrath
http://errfree.com // http://errtheblog.com
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2007-05-30 19:07
Thank you very much Chris
F1e1789ff9e7fc3032fa6cf15382a1e8?d=identicon&s=25 Juanma Cervera (jmcervera)
on 2007-06-02 10:03
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?
This topic is locked and can not be replied to.