Skip to content

Instantly share code, notes, and snippets.

@Agowan
Created September 11, 2012 18:09
Show Gist options
  • Save Agowan/3700422 to your computer and use it in GitHub Desktop.
Save Agowan/3700422 to your computer and use it in GitHub Desktop.
Without using squeel, default scope with sorting inherited to STI sub class
# encoding: utf-8
gem 'sqlite3', '1.3.6'
gem 'activerecord', '3.2.8'
require 'active_record'
require 'logger'
puts "Active Record #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)
ActiveRecord::Schema.define do
create_table :customers do |t|
t.string :name
t.string :type
t.datetime :start_at
end
end
class Customer < ActiveRecord::Base
default_scope order( :start_at )
end
class Company < Customer; end
Company.last
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment