Commit 000c032482dbe2fe882f3b2583fe1a481edf460a

Authored by Nihad Abbasov
1 parent 5e584ee6

display recent snippets at top

app/models/snippet.rb
@@ -22,6 +22,8 @@ class Snippet < ActiveRecord::Base @@ -22,6 +22,8 @@ class Snippet < ActiveRecord::Base
22 :presence => true, 22 :presence => true,
23 :length => { :within => 0..10000 } 23 :length => { :within => 0..10000 }
24 24
  25 + scope :fresh, order("created_at DESC")
  26 +
25 def self.content_types 27 def self.content_types
26 [ 28 [
27 ".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java", 29 ".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java",
app/views/snippets/index.html.haml
@@ -8,7 +8,7 @@ @@ -8,7 +8,7 @@
8 %th Title 8 %th Title
9 %th File name 9 %th File name
10 %th 10 %th
11 - = render @snippets 11 + = render @snippets.fresh
12 :javascript 12 :javascript
13 $('.delete-snippet').live('ajax:success', function() { 13 $('.delete-snippet').live('ajax:success', function() {
14 $(this).closest('tr').fadeOut(); }); 14 $(this).closest('tr').fadeOut(); });