Wierd pagination problem - Unknown options: order?


#1

I am trying to use pagination with the order option. I am following
examples I’ve seen all over the web, but I am getting an error. My code
seems simple:

def list
@upload_pages, @uploads = paginate :uploads, :per_page => 20, :order
=> ‘id’
end

Yet I keep getting this error:


ActionController::ActionControllerError in Data#list

Unknown options: order

/app/controllers/data_controller.rb:12:in `list’
/home/bclinton/work/eds/script/server:51


If I take the order option out, it works fine. Anyone have any idea
what I am doing wrong here?


#2

On 23-May-06, at 6:34 AM, Bill C. wrote:

end
Try putting your parameters in parentheses:

@upload_pages, @uploads = paginate ( :uploads, :per_page =>
20, :order => ‘id’)


#3

On 23-May-06, at 6:38 AM, Mike O. wrote:

Try putting your parameters in parentheses:

@upload_pages, @uploads = paginate ( :uploads, :per_page =>
20, :order => ‘id’)

oops - the space before/after the ( was unintentional.


#4

Mike O. wrote:

On 23-May-06, at 6:34 AM, Bill C. wrote:

end
Try putting your parameters in parentheses:

@upload_pages, @uploads = paginate ( :uploads, :per_page =>
20, :order => ‘id’)

Thanks for the suggestion, it was something I hadn’t tried.
Unfortunately I still get the same error. Here is my code now (the
commented line works):

def list
@upload_pages, @uploads = paginate(:uploads, :per_page => 20, :order
=> ‘id’)

@upload_pages, @uploads = paginate(:uploads, :per_page => 20)

end

Here is the beginning of the trace in case it helps:

/vendor/actionpack/lib/action_controller/pagination.rb:86:in
validate_options!' /vendor/actionpack/lib/action_controller/pagination.rb:110:inpaginate’
/vendor/actionpack/lib/action_controller/base.rb:756:in
perform_action_without_filters' /vendor/actionpack/lib/action_controller/filters.rb:295:inperform_action_without_benchmark’
/vendor/actionpack/lib/action_controller/benchmarking.rb:41:in
perform_action_without_rescue' /vendor/actionpack/lib/action_controller/benchmarking.rb:41:inmeasure’


#5

On 23-May-06, at 7:06 AM, Bill C. wrote:

Thanks for the suggestion, it was something I hadn’t tried.
Unfortunately I still get the same error. Here is my code now (the
commented line works):

def list
@upload_pages, @uploads = paginate(:uploads, :per_page =>
20, :order
=> ‘id’)

@upload_pages, @uploads = paginate(:uploads, :per_page => 20)

end

Are you using 1.1.2? :order option appears to have been added on
August 23 - you could check actionpack/lib/action_controller/
pagination.rb (around line 70) for :order in this:

 DEFAULT_OPTIONS = {
     :class_name => nil,
     :singular_name => nil,
     :per_page   => 10,
     :conditions => nil,
     :order_by   => nil,
     :order      => nil,
     :join       => nil,
     :joins      => nil,
     :count      => nil,
     :include    => nil,
     :select     => nil,
     :parameter  => 'page'
   }

I’m fairly new to this myself, so I’m not really sure what else to
suggest if your stuff is all current.


#6

Hello there,

Bill C. wrote:

Unknown options: order
I can’t really test it now but I think the problem is that the method
paginate does only expect two parameters, and you gave it three.

I would try something like this:

@upload_pages, @uploads = paginate :uploads, {:per_page => 20,
:order => ‘id’}

I hope that helps.

Greetings, Philipp

“They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety.” Benjamin Franklin
http://www.filzip.com