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