mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-15 21:55:29 +01:00
upgrade has_many_polymorphs
This commit is contained in:
parent
2d11109b8b
commit
f97ca2f6af
178 changed files with 132 additions and 108 deletions
|
|
@ -1,69 +0,0 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue