# A few steps for a database with polymorphic association?

**URL:** <https://www.ruby-forum.com/t/a-few-steps-for-a-database-with-polymorphic-association/190105>\
**Category:** Rails\
**Created:** [June 15, 2010, 11:22am UTC](https://www.ruby-forum.com/t/a-few-steps-for-a-database-with-polymorphic-association/190105 "2010-06-15T11:22:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![winterheat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/7993a0/32.png) [@winterheat](https://www.ruby-forum.com/u/winterheat)\
**Post date:** [June 15, 2010, 11:22am UTC](https://www.ruby-forum.com/t/a-few-steps-for-a-database-with-polymorphic-association/190105/1 "2010-06-15T11:22:13Z")

</div>

I thought it could be created in a few steps but it can’t yet:

```
rails poly
cd poly

ruby script/generate scaffold animal name:string obj_type:string

```

obj\_id:integer  
rake:migrate

```
ruby script/generate scaffold human name:string

```

passportNumber:string  
rake:migrate

```
ruby script/generate scaffold dog name:string

```

registrationNumber:string  
rake:migrate

and now change app/models/animal.rb to:

```
class Animal < ActiveRecord::Base
  belongs_to :obj, :polymorphic => true
end

```

and run

```
ruby script/server

```

and go to

```
http://localhost:3000

```

I thought on the server then if I create an Michael, Human, J123456  
and then Woofie, Dog, L23456

then the database will have entries in the Dogs table and “Humen” or  
“Humans” table as well as in the Animals table? But only the Animals  
table has records, Dogs and “Humen” do not for some reason. Is there  
some steps missing?
