Forum: Ruby on Rails Wierd pagination problem - Unknown options: order?

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.
76ade6a3bc9aadb33df39c735caf46f7?d=identicon&s=25 Bill Clinton (bclinton)
on 2006-05-23 13:34
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?
56493a3c223a155bbe2b44bdf55ef184?d=identicon&s=25 Mike Oligny (Guest)
on 2006-05-23 13:40
(Received via mailing list)
On 23-May-06, at 6:34 AM, Bill Clinton wrote:

>   end
Try putting your parameters in parentheses:

@upload_pages, @uploads = paginate ( :uploads, :per_page =>
20, :order => 'id')
56493a3c223a155bbe2b44bdf55ef184?d=identicon&s=25 Mike Oligny (Guest)
on 2006-05-23 13:44
(Received via mailing list)
On 23-May-06, at 6:38 AM, Mike Oligny 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.
76ade6a3bc9aadb33df39c735caf46f7?d=identicon&s=25 Bill Clinton (bclinton)
on 2006-05-23 14:06
Mike Oligny wrote:
> On 23-May-06, at 6:34 AM, Bill Clinton 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:in `paginate'
/vendor/actionpack/lib/action_controller/base.rb:756:in
`perform_action_without_filters'
/vendor/actionpack/lib/action_controller/filters.rb:295:in
`perform_action_without_benchmark'
/vendor/actionpack/lib/action_controller/benchmarking.rb:41:in
`perform_action_without_rescue'
/vendor/actionpack/lib/action_controller/benchmarking.rb:41:in `measure'
56493a3c223a155bbe2b44bdf55ef184?d=identicon&s=25 Mike Oligny (Guest)
on 2006-05-23 14:30
(Received via mailing list)
On 23-May-06, at 7:06 AM, Bill Clinton 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.
C0e88794fe56ccfaaa57e32f9b4e9222?d=identicon&s=25 Philipp Engel (Guest)
on 2006-05-23 17:02
(Received via mailing list)
Hello there,

Bill Clinton 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
This topic is locked and can not be replied to.