# Has\_many\_polymorphs

**URL:** <https://www.ruby-forum.com/t/has-many-polymorphs/130547>\
**Category:** Rails\
**Created:** [February 29, 2008, 7:56am UTC](https://www.ruby-forum.com/t/has-many-polymorphs/130547 "2008-02-29T07:56:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Ukhov](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/977dab/32.png) [@Ivan\_Ukhov](https://www.ruby-forum.com/u/Ivan_Ukhov)\
**Post date:** [February 29, 2008, 7:56am UTC](https://www.ruby-forum.com/t/has-many-polymorphs/130547/1 "2008-02-29T07:56:27Z")

</div>

Hello

Has anyone tried to use the has\_many\_polymorphs plugin? I have added  
the following line into environment.rb just before  
Rails::Initializer.run:

require ‘has\_many\_polymorphs’

… created two models:

class CreateOwnerships \< ActiveRecord::Migration  
def self.up  
create\_table :ownerships do |t|  
t.references :owner, :polymorphic =\> true  
t.references :property, :polymorphic =\> true  
t.column :created\_on, :timestamp  
end  
end

def self.down  
drop\_table :ownerships  
end  
end

class CreateTasks \< ActiveRecord::Migration  
def self.up  
create\_table :tasks do |t|  
t.column :name, :string, :null =\> false  
t.column :description, :text  
t.column :complete, :boolean, :null =\> false  
t.column :weight, :float, :null =\> false  
end  
end

def self.down  
drop\_table :tasks  
end  
end

and tried to run `rake db:migrate` and got the following message:

\*\* has\_many\_polymorphs: rails environment detected  
\*\* has\_many\_polymorphs: preloading parent model Ownership  
\*\* has\_many\_polymorphs: Ownership could not be preloaded:  
#\<ActiveRecord::StatementInvalid: Mysql::Error: Table  
‘mydb.ownerships’ doesn’t exist: SHOW FIELDS FROM ownerships\>  
rake aborted!

what’s wrong?

Thanks
