# AR Models in Module

**URL:** <https://www.ruby-forum.com/t/ar-models-in-module/142846>\
**Category:** Rails\
**Created:** [July 12, 2008, 2:17am UTC](https://www.ruby-forum.com/t/ar-models-in-module/142846 "2008-07-12T02:17:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [July 12, 2008, 2:17am UTC](https://www.ruby-forum.com/t/ar-models-in-module/142846/1 "2008-07-12T02:17:27Z")

</div>

Hello all,

I have a module, illustrated below, with a few classes. I have required  
environment.rb and can access my models just fine outside the module,  
and even within the module’s root, but once I try and access one inside  
a module class I get an uninitialized constant error. Anyone know how I  
can access these models within these module classes?

# Module Illustration

module Foo  
puts Chapter.find(x).attr ## Works

Class Bar \< SuperClass  
puts Chapter.find(x).attr ## Fails, uninitialized constant  
Foo::Bar::Chapter  
puts ActiveRecord::Chapter.find(x).attr ## Fails, uninitialized  
constant ActiveRecord::Chapter  
end  
end

---

<div class="post-metadata">

**Author:** ![mrpunkin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b5a626/32.png) [@mrpunkin](https://www.ruby-forum.com/u/mrpunkin)\
**Post date:** [July 14, 2008, 5:14pm UTC](https://www.ruby-forum.com/t/ar-models-in-module/142846/2 "2008-07-14T17:14:25Z")

</div>

Anyone? Please help me out with this.
