# Getting the module of a class

**URL:** <https://www.ruby-forum.com/t/getting-the-module-of-a-class/87287>\
**Category:** Ruby\
**Created:** [March 26, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/getting-the-module-of-a-class/87287 "2006-03-26T17:30:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nexflo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/58956e/32.png) [@nexflo](https://www.ruby-forum.com/u/nexflo)\
**Post date:** [March 26, 2006, 5:30pm UTC](https://www.ruby-forum.com/t/getting-the-module-of-a-class/87287/1 "2006-03-26T17:30:07Z")

</div>

Hi!

Can anybody think of a better way to get the module of a class in a  
module?

eval(some\_class\_in\_a\_module.to\_s.gsub(/::[^:]\*$/, ‘’))

Thanks!

Ciao!  
Florian
