Simple question for composed_of

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!

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.