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? -%> <div id="admin"> <ul> <li><%= link_to "New article", new_article_path %></li> <li><%= link_to "New project", new_project_path %></li> <%= yield :admin %> <li><%= link_to "Logout", logout_path %></li> </ul> <p class="flash"><%= flash[:notice] %></p> </div> <% end -%> Any tips on a different way of doing the admin interface that don't involve duplication like /admin/....?
on 2009-03-02 19:03
on 2009-03-02 19:47
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.