Fetch updates in reverse chronological order by default.

This commit is contained in:
Miles Gould
2012-11-09 10:13:16 +00:00
parent ed896dd7a5
commit e6eb30fbbf
2 changed files with 6 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
class Update < ActiveRecord::Base
attr_accessible :body, :subject, :user_id
belongs_to :user
default_scope order("created_at desc")
end

View File

@@ -1,5 +1,9 @@
require 'spec_helper'
describe Update do
pending "add some examples to (or delete) #{__FILE__}"
it "should be sorted in reverse order" do
Update.create! :subject => "first entry", :body => "blah", :user_id => 1
Update.create! :subject => "second entry", :body => "blah", :user_id => 1
Update.first.subject.should == "second entry"
end
end