Skip to content

Commit

Permalink
Bug Fix: Explicitly ordered comments to force consistency across data…
Browse files Browse the repository at this point in the history
…base vendors(e.g. MySQL, SQLite, PostgreSQL, etc.)
  • Loading branch information
tiandavis committed Jan 29, 2011
1 parent 1a035dd commit 2f2347a
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/views/archives/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<% if current_user %>
<% if post.comments.count > 0 %>
<span class="comments"><%= post.comments.count %></span>
<span class="latest"><%= post.comments.all.last.created_at.strftime("%b %d %Y") %></span>
<span class="latest"><%= post.comments.order("created_at ASC").last.created_at.strftime("%b %d %Y") %></span>
<% end %>
<% end %>
</li>
Expand Down
2 changes: 1 addition & 1 deletion app/views/posts/_meta.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
<%= link_to "Post a comment", post_path(post, :anchor => "comments") %>
<% else %>
<%= link_to pluralize(post.comments.count, "comment"), post_path(post, :anchor => "comments") %>
Latest by <%= post.comments.all.last.name %>
Latest by <%= post.comments.order("created_at ASC").last.name %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<h2 class="comment_count"><%= pluralize(@post.comments.count, "comment") %> so far</h2>

<div id="comments" class="comments">
<% for comment in @post.comments.all %>
<% for comment in @post.comments.order("created_at ASC") %>
<%= render :partial => comment, :locals => { :post => @post } %>
<% end %>
</div><!--comments-->
Expand Down
Binary file modified db/blogcast_development.sqlite3
Binary file not shown.

0 comments on commit 2f2347a

Please sign in to comment.