# Simple question for composed\_of

**URL:** <https://www.ruby-forum.com/t/simple-question-for-composed-of/112549>\
**Category:** Rails\
**Created:** [August 20, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/simple-question-for-composed-of/112549 "2007-08-20T20:12:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [August 20, 2007, 8:12pm UTC](https://www.ruby-forum.com/t/simple-question-for-composed-of/112549/1 "2007-08-20T20:12:00Z")

</div>

Hi All,

Here’s a n00b question for composed\_of. In what file do you put the  
class that is used for the composed\_of?

For example, let’s say that you have the code below:

class Declaration \< ActiveRecord::Base  
composed\_of :amount, :class\_name =\> “Currency”, :mapping =\>  
%w(amount amount)  
end

class Currency  
attr\_accessor :round, :decimal, :amount

def initialize(amount)  
self.amount = amount  
self.round = amount.to\_i.to\_s[0…-3]  
self.decimal = amount.to\_i.to\_s[-2…-1]  
end

end

In what file do you put the code for the class Currency? Thanks!

---

<div class="post-metadata">

**Author:** ![dparkmit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dparkmit](https://www.ruby-forum.com/u/dparkmit)\
**Post date:** [August 30, 2007, 11:26pm UTC](https://www.ruby-forum.com/t/simple-question-for-composed-of/112549/2 "2007-08-30T23:26:56Z")

</div>

I would put your class Currency in a file under “apps/models/  
currency.rb”

It should load the file currency.rb file automatically, since it’s in  
the models folder.
