From 000c032482dbe2fe882f3b2583fe1a481edf460a Mon Sep 17 00:00:00 2001 From: Nihad Abbasov Date: Thu, 27 Oct 2011 12:14:50 +0500 Subject: [PATCH] display recent snippets at top --- app/models/snippet.rb | 2 ++ app/views/snippets/index.html.haml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/snippet.rb b/app/models/snippet.rb index acffc76c..44cb8887 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -22,6 +22,8 @@ class Snippet < ActiveRecord::Base :presence => true, :length => { :within => 0..10000 } + scope :fresh, order("created_at DESC") + def self.content_types [ ".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java", diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml index fe5e6170..3f261000 100644 --- a/app/views/snippets/index.html.haml +++ b/app/views/snippets/index.html.haml @@ -8,7 +8,7 @@ %th Title %th File name %th - = render @snippets + = render @snippets.fresh :javascript $('.delete-snippet').live('ajax:success', function() { $(this).closest('tr').fadeOut(); });