Skip to content

Instantly share code, notes, and snippets.

@eoy
Last active December 22, 2015 16:29
Show Gist options
  • Save eoy/6499494 to your computer and use it in GitHub Desktop.
Save eoy/6499494 to your computer and use it in GitHub Desktop.
Manaflask competition comments explanation
  1. User sees article without the question
  2. User clicks pagination or posts a comment
  3. Comments are refreshed showing the latest comments (old comments + all new since you posted)
  4. User still sees article without the question
  5. User now navigates to page 5 and sees someone answered the question while the article (to him) doesn't contain the question
  6. User rages!
  7. User takes screenshot of Hans saying he will post at 18:30, Hans posted at ~18:29:20

Comments are refreshed every time you post a comment or click a page in the navigation, without refreshing the rest of the article. This is what happened. If someone would be cheating we'd be sure to catch them.

$('.js-comments-container').html('<%= j render :partial => "shared/comment/list", :locals => { :entity => @article, :comments => @comments } %>');
$('.timeago').timeago();
<% cache(cache_key_for_comments(@article, comments, (params[:page] || "first")) ) do %>
  <%= render :partial => "shared/comment/light_comment", :collection => comments, :locals => { :entity => entity } %>
<% end %>
<% cache ["v1", light_comment] do %>
<li class="comment">
  <article class="comments--comment">
    <figure class="avatar small" role="author-avatar">
      <%= UserDecorator.decorate(comment.user).avatar if comment.user.present? %>
      <% if comment.user.present? && comment.user.guild.present? %>
        <%= UserDecorator.decorate(comment.user).guild_logo %>
      <% end %>
    </figure>

    <div class="comments--body" role="comment-body">
      <span class="comments--meta">
        <% if comment.user.present? %>
          <%= link_to comment.user.name, comment.user %>&nbsp;<small><%= timeago(comment.created_at) %></small>&nbsp;&mdash;
        <% end %>
      </span>
      <span class="js-comment-body">
        <%= sanitize(comment.body).gsub("\r\n", "<br/>").html_safe %> 
        <% if user_signed_in? %>
          <i class="icon-reply js-reply tipme" title="Reply" data-placement="top"></i>
        <% end %>
      </span>
    </div>
  </article>
</li>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment