# Linking to "Next Entry \>\>" from the current Entry Page

**URL:** <https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006>\
**Category:** Rails\
**Created:** [April 17, 2008, 12:39am UTC](https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006 "2008-04-17T00:39:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 17, 2008, 12:39am UTC](https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006/1 "2008-04-17T00:39:12Z")

</div>

Hi all,

I’m trying to link to the “Next Entry \>\>” from the current entry page  
(in show.html.erb).

Any one know how I would do it?

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 17, 2008, 5:23am UTC](https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006/2 "2008-04-17T05:23:00Z")

</div>

The best thing would be to set a @next\_entry instance variable in the  
controller so that it’s available to the view. Then you can just link  
to that directly. The problem with trying to get “next entry” from  
“current entry” is how that is defined. Is it the next incremental ID?  
What if some are deleted? Set the logic in the controller so that the  
view can just “be the view”.

-Danimal

On Apr 16, 4:39 pm, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 17, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006/3 "2008-04-17T14:20:28Z")

</div>

Danimal wrote:

> The best thing would be to set a @next\_entry instance variable in the  
> controller so that it’s available to the view. Then you can just link  
> to that directly. The problem with trying to get “next entry” from  
> “current entry” is how that is defined. Is it the next incremental ID?  
> What if some are deleted? Set the logic in the controller so that the  
> view can just “be the view”.
> 
> -Danimal
> 
> On Apr 16, 4:39 pm, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

Thanks for the suggestion, Danimal! I could see many conflicts with the  
id linking.

I just discovered acts\_as\_ordered before I saw your post, which is a  
wonderful little plugin that I’d highly recommend as another option.

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [April 17, 2008, 3:53pm UTC](https://www.ruby-forum.com/t/linking-to-next-entry-from-the-current-entry-page/135006/4 "2008-04-17T15:53:34Z")

</div>

Oooh! I just read the README from acts\_as\_ordered. That’s a pretty  
slick plugin!

And with it, you can toss out my advice above cause you can just say:  
@entry.next in your link\_to

Slick!

-Danimal

On Apr 17, 6:20 am, Bob S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
