Sha256: 196d48067930470b68fc9b130a4ed760b868ccadd1c8503e13e033c35e2c6016
Contents?: true
Size: 898 Bytes
Versions: 1
Compression:
Stored size: 898 Bytes
Contents
require 'rubygems' require 'active_record' require 'acts_as_relation' ActiveRecord::Base.establish_connection( :adapter => "sqlite3", :database => ":memory:" ) ActiveRecord::Schema.define(:version => 1) do create_table :stores do |t| t.string :store_name end create_table :products, :as_relation_superclass => true do |t| t.string :name t.float :price end create_table :pens, :as_relation_superclass => true do |t| t.string :color end create_table :pencils end class Store < ActiveRecord::Base has_many :products end class Product < ActiveRecord::Base acts_as_superclass belongs_to :store validates_presence_of :name, :price def parent_method "#{name} - #{price}" end end class Pen < ActiveRecord::Base acts_as_superclass acts_as :product validates_presence_of :color end class Pencil < ActiveRecord::Base acts_as :pen end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
acts_as_relation-0.0.5 | test/schema.rb |