I am trying to use composed_of in my model, but I not succeeding.
With the code I pasted below, I cannot perform this action in the console:
property = Property.new(1, "px")
I get NameError: uninitialized constant Property when I try to perform
that action. It''s not finding my class I made I suppose. The Property
class is in the same file as the Element class, element.rb.
Does anyone know how to do this?
Thanx for any and all info.
Code...
# My model is simple:
class Element < ActiveRecord::Base
composed_of :fontsize,
:class_name => "Property",
:mapping =>
[
%w(font_size amount),
%w(font_size_unit unit)
]
end
# My class for this is simple:
class Property
attr_reader :amount, :unit
def intialize(amount, unit)
@amount = amount
@unit = unit
end
def to_s
@amount.to_s + @unit
end
end
--
://
Nathan Herald