I don't know of any, sorry.

In the past I've written two simple instance methods and two
named_scopes in my models.

named_scope :next, lambda {|post, user|
  { :conditions => ["created_at > ? and user_id = ?", post.created_at,
user.id], :order => "created_at ASC" }
}

named_scope :prev, lambda {|post, user|
  { :conditions => ["created_at < ? and user_id = ?", post.created_at,
user.id], :order => "created_at DESC" }
}

def next(user)
  Post.next(self, user).first
end

def prev(user)
  Post.prev(self, user).first
end

On Nov 20, 6:50 pm, [EMAIL PROTECTED] wrote:
> Anyone know of a plugin or gem that would create methods such as next
> and previous on a model to traverse among siblings? For example,
> @post.next and @post.prev.
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to