Permalink
Browse files

moved hmph.rb to trunk/examples and made sure I used plural table names

  • Loading branch information...
1 parent d40e85e commit d15aa0e7e70f7d598bf84b91368def647c2f4697 Beppu committed Sep 15, 2007
Showing with 69 additions and 0 deletions.
  1. +69 −0 examples/hmph.rb
View
@@ -0,0 +1,69 @@
+require 'camping'
+require 'has_many_polymorphs'
+
+Camping.goes :Hmph
+
+module Hmph::Models
+ class GuestsKennel < Base
+ belongs_to :kennel
+ belongs_to :guest, :polymorphic => true
+ end
+
+ class Dog < Base
+ end
+
+ class Cat < Base
+ end
+
+ class Bird < Base
+ end
+
+ class Kennel < Base
+ has_many_polymorphs :guests,
+ :from => [:dogs, :cats, :birds],
+ :through => :guests_kennels,
+ :namespace => :"hmph/models/"
+ end
+
+ class InitialSchema < V 1.0
+ def self.up
+ create_table :hmph_kennels do |t|
+ t.column :created_at, :datetime
+ t.column :modified_at, :datetime
+ t.column :name, :string, :default => 'Anonymous Kennel'
+ end
+
+ create_table :hmph_guests_kennels do |t|
+ t.column :guest_id, :integer
+ t.column :guest_type, :string
+ t.column :kennel_id, :integer
+ end
+
+ create_table :hmph_dogs do |t|
+ t.column :name, :string, :default => 'Fido'
+ end
+
+ create_table :hmph_cats do |t|
+ t.column :name, :string, :default => 'Morris'
+ end
+
+ create_table :hmph_birds do |t|
+ t.column :name, :string, :default => 'Polly'
+ end
+ end
+
+ def self.down
+ drop_table :hmph_kennels
+ drop_table :hmph_guests_kennels
+ drop_table :hmph_dogs
+ drop_table :hmph_cats
+ drop_table :hmph_birds
+ end
+ end
+end
+
+module Hmph::Controllers
+end
+
+module Hmph::Views
+end

0 comments on commit d15aa0e

Please sign in to comment.