# Admin links

**URL:** <https://www.ruby-forum.com/t/admin-links/161811>\
**Category:** Rails\
**Created:** [March 2, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/admin-links/161811 "2009-03-02T18:03:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yaphi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e274bd/32.png) [@yaphi](https://www.ruby-forum.com/u/yaphi)\
**Post date:** [March 2, 2009, 6:03pm UTC](https://www.ruby-forum.com/t/admin-links/161811/1 "2009-03-02T18:03:29Z")

</div>

Is there a better way to show admin link than this? I want to  
implement page caching but can’t due to it not having conditions.  
Fragment caching seems wrong for my site since every page should be  
cached except I have this toolbar div shown in the layout if the user  
is logged in.

\<% if logged\_in? -%\>

- \<%= link\_to "New article", new\_article\_path %\>
- \<%= link\_to "New project", new\_project\_path %\>
 \<%= yield :admin %\> - \<%= link\_to "Logout", logout\_path %\>

\<%= flash[:notice] %\>

 \<% end -%\>

Any tips on a different way of doing the admin interface that don’t  
involve duplication like /admin/…?

---

<div class="post-metadata">

**Author:** ![yaphi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/e274bd/32.png) [@yaphi](https://www.ruby-forum.com/u/yaphi)\
**Post date:** [March 2, 2009, 6:47pm UTC](https://www.ruby-forum.com/t/admin-links/161811/2 "2009-03-02T18:47:35Z")

</div>

yaphi wrote:

> Is there a better way to show admin link than this? I want to  
> implement page caching but can’t due to it not having conditions.  
> Fragment caching seems wrong for my site since every page should be  
> cached except I have this toolbar div shown in the layout if the user  
> is logged in.

So cache all your fragments…

one fragment is the toolbar div, the other fragment is the rest of the  
page (effectively your ‘page’ caching).

I cache a left-nav fragment (effectively the admin versus not admin  
menu), the main area fragment (for show or index, edit/new not cached),  
and a right-nav fragment (a context menu of related models based on what  
currently appears in the main area. the context-nav is itself a fragment  
cache of multi-tiered fragments - the retrieval of all the related  
models of a given model can be very expensive, so for a given model  
instance, each type of related model has its own fragment). Takes a bit  
to get used to for devs new to the project, but its easily an order of  
magnitude faster to assemble fragments. Relating a new model just  
invalidates that “related model type” fragment and the overall “related  
models” fragment.
