Sha256: a2a71d6234fbfc7ab1269521cd23fd19a46e048b329d40573265f390140cdf87

Contents?: true

Size: 1.39 KB

Versions: 20

Compression:

Stored size: 1.39 KB

Contents

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

Version data entries

20 entries across 20 versions & 4 rubygems

Version Path
radiant-tags-extension-1.6.10 vendor/plugins/has_many_polymorphs/examples/hmph.rb
johnsbrn-has_many_polymorphs-2.13 examples/hmph.rb
radiant-tags-extension-1.6.9 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.8 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.7 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.6 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.5 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.4 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.3 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.2 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.1 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.6.0 vendor/plugins/has_many_polymorphs/examples/hmph.rb
radiant-tags-extension-1.5.1 vendor/plugins/has_many_polymorphs/examples/hmph.rb
has_many_polymorphs-2.13 examples/hmph.rb
has_many_polymorphs-2.11 examples/hmph.rb
has_many_polymorphs-2.2 examples/hmph.rb
has_many_polymorphs-2.12 examples/hmph.rb
spree-0.6.0 vendor/plugins/has_many_polymorphs/examples/hmph.rb
spree-0.7.0 vendor/plugins/has_many_polymorphs/examples/hmph.rb
spree-0.7.1 vendor/plugins/has_many_polymorphs/examples/hmph.rb