# Model

**URL:** <https://www.ruby-forum.com/t/model/166941>\
**Category:** Rails\
**Created:** [May 1, 2009, 8:09am UTC](https://www.ruby-forum.com/t/model/166941 "2009-05-01T08:09:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![amita0204](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@amita0204](https://www.ruby-forum.com/u/amita0204)\
**Post date:** [May 1, 2009, 8:09am UTC](https://www.ruby-forum.com/t/model/166941/1 "2009-05-01T08:09:52Z")

</div>

Hi,

Should every model have an associated table in database? I have a model  
as a subclass of another model class. I am getting ‘MySQL gone away’  
error while creating a new object of this subclass.

Any clues?

- 

Amita.

---

<div class="post-metadata">

**Author:** ![amita0204](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@amita0204](https://www.ruby-forum.com/u/amita0204)\
**Post date:** [May 1, 2009, 9:53am UTC](https://www.ruby-forum.com/t/model/166941/2 "2009-05-01T09:53:13Z")

</div>

On May 1, 7:09 am, Amita B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi,
> 
> Should every model have an associated table in database? I have a model  
> as a subclass of another model class.

not necessarily. For example when using single table inheritance then  
a model and its subclasses will share a table, and you can of course  
have non-activerecord model classes that don;t use the database at  
all.

Fred

---

<div class="post-metadata">

**Author:** ![amita0204](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@amita0204](https://www.ruby-forum.com/u/amita0204)\
**Post date:** [May 1, 2009, 3:15pm UTC](https://www.ruby-forum.com/t/model/166941/3 "2009-05-01T15:15:25Z")

</div>

> I am getting ‘MySQL gone away’  
> error while creating a new object of this subclass.

Refactor the common code between your tabled and table-less \*models into  
a  
module, and let both models include that module.

\*yes, it’s still a model, even if it has no DB persistence.

–  
Phlip  
[http://flea.sourceforge.net/resume.html](http://flea.sourceforge.net/resume.html)
