俄罗斯娃娃在铁轨上缓存

俄罗斯娃娃在铁轨上缓存

本文介绍了俄罗斯娃娃在铁轨上缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听过DHH和其他37Signal优秀人士谈论了很多关于俄罗斯玩偶缓存的问题,我了解它的概念,但是我真的不知道如何将其应用于我的代码.

I've heard DHH and the other great 37Signal guys talk a lot about Russian Doll Caching and I understand the concept of it, but I don't really know how to apply it to my code.

您将如何应用它?

新您如何将gem应用于带有许多if语句的一段代码?

NEWHow would you apply the gem to a piece of code with a lot of if statements?

    <% if signed_in? %>
      <div class="timeline">
        <%= link_to image_tag(current_user.avatar), designer_path(current_user), :class => "avatar topimg" %>
        <%= content_tag(:span, "your profile", :class => "description") %>
        <%= link_to "", new_design_path, :class => "upload icon-upload" %>
        <%= content_tag(:span, "upload a new design", :class => "description") %>
        <%= link_to "", designer_path(current_user)+"/favorites", :class => "upload icon-star" unless current_user.followees_by_type("design").blank? %>
        <%= content_tag(:span, "designs you've favorited", :class => "description") unless current_user.followees_by_type("design").blank? %>
        <%= content_tag(:span, current_user.current_invites, :class => "invites_count") unless current_user.current_invites <= 0 || current_user.full_member == false %>
        <%= link_to "", "#", :class => "invite icon-plus "+("blue" unless current_user.current_invites == 0).to_s unless current_user.current_invites < 0 || current_user.full_member == false  %>
        <%= content_tag(:span, "invite a friend ("+current_user.current_invites.to_s+" invites left)", :class => "description") unless current_user.current_invites < 0  %>
        <%= content_tag(:span, activity, :class => "activity_count") unless activity == 0 %>
        <%= link_to "", designer_path(current_user)+"/statistics", :class => "upload icon-activity "+("blue" unless activity == 0).to_s unless activity == 0 %>
        <%= content_tag(:span, ("your activity ("+pluralize(activity, 'new thing')+")"), :class => "description") unless activity == 0%>
      </div>
    <% else %>
      <%= link_to raw('<i class="icon-twitter icon-font"></i><span>login with twitter</span>'), "/auth/twitter", :class => "btn btn-twitter grey-tweet" %>
    <% end %>

推荐答案

查看宝石,他们发布,它有一些不错的文档.

Check out the Gem that they released, it has some decent documentation.

这篇关于俄罗斯娃娃在铁轨上缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 15:08