Bohm
1
Hi,
does anybody have a good way of handling aggregates in forms?
I have an aggregate object Money that is holds the price of an item. So
my Item would contain a reference to Money:
composed_of :price,
:class_name => Money,
:mapping => [[:price_amount, :amount],
[:price_currency,
:currency]
Since the form helpers don’t support nesting, how do I display the price
in the form?
Do I have to use a workaround something like:
Any help would be really appreciated
Thanks
Peter
Bohm
2
Hi Peter,
Maybe you could define a couple of methods to set and get according to
your
requriements
def price_ammount
some stuff
end
def price_ammount=(a_price)
some stuff
end
Then in your view you could use those as though they are fields.
I think this should work, I haven’t tested it tho.
Cheers
Dan
Bohm
3
Bohm
4
Peter B. wrote:
I only wish the rails supported nested parameters - for both
associations and aggregates
Peter, here’s the patch for this to which I referred in the
earlier thread: http://dev.rubyonrails.org/ticket/2053
–
We develop, watch us RoR, in numbers too big to ignore.
Bohm
5
Hi Mark,
thank you very much - seems to be exactly what I need
It’s 2:35am - will have a look at it tomorrow morning
thanks
Peter