# STI class\_name returns the parent class name

**URL:** <https://www.ruby-forum.com/t/sti-class-name-returns-the-parent-class-name/145370>\
**Category:** Rails\
**Created:** [August 8, 2008, 2:33pm UTC](https://www.ruby-forum.com/t/sti-class-name-returns-the-parent-class-name/145370 "2008-08-08T14:33:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonypm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@tonypm](https://www.ruby-forum.com/u/tonypm)\
**Post date:** [August 8, 2008, 2:33pm UTC](https://www.ruby-forum.com/t/sti-class-name-returns-the-parent-class-name/145370/1 "2008-08-08T14:33:19Z")

</div>

Is this a bug or intended action - or am I missing something.

If I have  
class Thing \< ActiveRecord::Base  
and  
class ZThing \< Thing

and I do

z=ZThing.create

Then z.class  
returns ZThing(id: …etc  
as I would expect

but z.class.class\_name  
returns Thing

which is a problem when I want to test for my STI class. Or should I  
check for STI class name in a different way?

Thanks  
Tonypm.
