How to use aggregates in a form

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],


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 :slight_smile:



Hi Peter,

Maybe you could define a couple of methods to set and get according to

def price_ammount
some stuff

def price_ammount=(a_price)
some stuff

Then in your view you could use those as though they are fields.

I think this should work, I haven’t tested it tho.


Rails mailing list
[email protected]

Peter B. wrote:

I only wish the rails supported nested parameters - for both
associations and aggregates :slight_smile:

Peter, here’s the patch for this to which I referred in the
earlier thread:

We develop, watch us RoR, in numbers too big to ignore.

Hi Mark,
thank you very much - seems to be exactly what I need :slight_smile:

It’s 2:35am - will have a look at it tomorrow morning



This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs