Michael Breen
2008-Jun-10 18:30 UTC
What would be the best way to get next and previous record?
Let''s say I have a class Post and I do a simple find for a record, like Post.find(16). Given this AR instance what would be the best way to get the previous and next records? I can''t just use ids (15, 17 in this example) because records can be deleted. Am I asking AR to do too much here and craft some custom SQL to handle this? Thanks for the help. Mike --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mike Breen
2008-Jun-10 18:49 UTC
Re: What would be the best way to get next and previous record?
found it! http://svn.viney.net.nz/things/rails/plugins/acts_as_ordered/README On Jun 10, 2:30 pm, Michael Breen <hard...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Let''s say I have a class Post and I do a simple find for a record, > like Post.find(16). Given this AR instance what would be the best way > to get the previous and next records? I can''t just use ids (15, 17 in > this example) because records can be deleted. > > Am I asking AR to do too much here and craft some custom SQL to handle > this? > > Thanks for the help. > Mike--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---