# Calling a Model Class within a Library Module?

**URL:** <https://www.ruby-forum.com/t/calling-a-model-class-within-a-library-module/78127>\
**Category:** Rails\
**Created:** [December 3, 2006, 12:09am UTC](https://www.ruby-forum.com/t/calling-a-model-class-within-a-library-module/78127 "2006-12-03T00:09:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Pitman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/8e7dd6/32.png) [@David\_Pitman](https://www.ruby-forum.com/u/David_Pitman)\
**Post date:** [December 3, 2006, 12:09am UTC](https://www.ruby-forum.com/t/calling-a-model-class-within-a-library-module/78127/1 "2006-12-03T00:09:16Z")

</div>

I’m trying to call a Model class within a lib/ module with no success.  
Here’s what I’m working with:  
======================= lib/foo\_module.rb ======================  
require “pp”  
module Foo\_Module

def Foo\_Module.import\_database  
barmodel = BarModel.find\_all()

end

module ForeignTables  
#Unimportant stuff in here  
end

end  
======================end lib/foo\_module.rb ====================

When I try to run “Foo\_Module.import\_database” in the console, I get  
this error:  
NameError: uninitialized constant BarModel

BarModel was constructed with the model generator. Any ideas? I feel  
like I’m just not referencing BarModel correctly. Should it  
Models::BarModel or something?
