#rubyonrails - Sun 25 Feb 2007 between 01:45 and 01:54



lbuenaventuracould someone help me figure out how to pull off efficient windowed pagination?
i have a photo gallery, and when a user views an individual picture, i want to have a window of 8 other images
pstickneas much as everyone swears against the standard pagination...
lbuenaventurathe 8 images should represent, ideally 4 images to the left, and 4 images to the right of the image
pstickne...it works pretty easily.
the layout of the images is simply in how you create the view
lbuenaventurai'm not sure i can pull this off with standard pagination
psticknewhy not
lbuenaventuralet's say i give you the id of the individual image
i need to be able to pull out the ids of 8 other images that "surround" it in the database table
psticknewhy thank you, it's a rather sexy id.
okay. you can use the paginator with your own search results.
christophe971i'm drunk and sick ! it's the better time to RoR o/ !
let's code
lbuenaventurahow wouldi compute the offset?
pstickne*shrug*
which thing is actually moving? just the one item in the middle?
lbuenaventurayes, exactly
psticknethen the step is just one
that sounds icky
lbuenaventurasorry what do you mean?
pstickneit sounds like a really messy sql query
lbuenaventurai know, but the UI needs it
psticknebecause you're relying on relative position of rows
lbuenaventurayes
so i was wondering if perhaps there was a helper already out there that could do it
or some other way around the problem
pstickneI think the best way would be to change the table format slightly... but I'm not sure how. If there was a way you could guarentee proximity... even when say, things are removed.
such as with an arbitary re-created index
lbuenaventurathe main issue is that the query also has conditions like "private<>1" and whatnot
pstickne...
uhm.
:)
lbuenaventuraso the data set you're pulling out is not necessarily sequential
it's truly relative
pstickneokay, here it goes...
sgroverI thought scripttaculous was included with rais, no? I'm getting told Builder is undefined (builder.js is not available)
psticknesearch for what you're looking for, sort id, limit, search <= that id, maybe with a lower bounds, reverse sort and limit
and that sounds ugly
lbuenaventurayes, it sounds like something i'd do in php

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 93 

IrcArchive