Forum: Ruby on Rails Which page an object is from

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.
Paul P. (Guest)
on 2007-01-07 22:17
Hi all,
is it possible to figure out which page a particular object belongs to?
Say i have a paginated list of 10 image objects over 5 pages, and I have
a list of thumbnails along the bottom of all 10 objects. the id's of
these aren't in order, so i can't figure it out that way. can i query my
@object_pages somehow to figure it out?

i hope that's clear enough - i don't understand this very well :)
harper (Guest)
on 2007-01-08 11:42
Paul PH wrote:
> Hi all,
> is it possible to figure out which page a particular object belongs to?
> Say i have a paginated list of 10 image objects over 5 pages, and I have
> a list of thumbnails along the bottom of all 10 objects. the id's of
> these aren't in order, so i can't figure it out that way. can i query my
> @object_pages somehow to figure it out?

((from api.rubyonrails.com))

   find_collection_for_pagination(model, options, paginator)


..kinda the oppisite of what you need (it checks what objects belong to
a @object_page) but is this of any help?
harper (Guest)
on 2007-01-08 11:46
...you can also use the order option on the paginator, so it will order
it by your own means (you could order the 10 images by their id if it
makes your life easier)


def ...

paginate :objects, blah blah ...
:conditions => ...
:order => 'whateverattributeyouwant asc' # this is what you want?
...

end

helping?
Paul P. (Guest)
on 2007-01-08 12:05
harper wrote:
> ...you can also use the order option on the paginator, so it will order
> it by your own means (you could order the 10 images by their id if it
> makes your life easier)
>
>
> def ...
>
> paginate :objects, blah blah ...
> :conditions => ...
> :order => 'whateverattributeyouwant asc' # this is what you want?
> ...
>
> end
>
> helping?

thanks for the replies - i'll try these out later.

cheers,
Fox
This topic is locked and can not be replied to.