# Create custom class

**URL:** <https://www.ruby-forum.com/t/create-custom-class/131056>\
**Category:** Rails\
**Created:** [March 5, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/create-custom-class/131056 "2008-03-05T17:27:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [March 5, 2008, 5:27pm UTC](https://www.ruby-forum.com/t/create-custom-class/131056/1 "2008-03-05T17:27:36Z")

</div>

hi all,

I want to make a custom data class. Where do I best store that class  
in my rails structure? Do I need to include that class somewhere ?

Thanks  
Stijn

---

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [March 5, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/create-custom-class/131056/2 "2008-03-05T17:32:44Z")

</div>

Tarscher wrote:

> I want to make a custom data class. Where do I best store that class  
> in my rails structure? Do I need to include that class somewhere ?

If this is a class that doesn’t have a database table, you can put it  
into a file with the same name as the class but lowercase (and ending in  
“.rb”) in the “lib” directory. So for an Item class, add:

lib/item.rb

When you refer to the class, this is one of the places Rails  
automatically looks.

---

<div class="post-metadata">

**Author:** ![Tarscher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@Tarscher](https://www.ruby-forum.com/u/Tarscher)\
**Post date:** [March 5, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/create-custom-class/131056/3 "2008-03-05T17:49:25Z")

</div>

Tarscher wrote:

> hi all,
> 
> I want to make a custom data class. Where do I best store that class  
> in my rails structure? Do I need to include that class somewhere ?
> 
> Thanks  
> Stijn

Usually that would go in RAILS\_ROOT/lib. You can then ‘require’ it in  
your environment.rb.

–  
[http://www.5valleys.com/](http://www.5valleys.com/)  
[http://www.workingwithrails.com/person/8078](http://www.workingwithrails.com/person/8078)
