There's no way to do this with rich-types right now but I think it's a great idea.
Could you put a ticket on the Hobo lighthouse tagged 'enhancement'. I don't think it will make it in to 1.0 but I'd like to see this added. Thanks Tom On 8 Jun 2009, at 03:32, Ritchie Young wrote: > > Hi, > > I've just started with Hobo about a week ago and I'm really enjoying > it. It definitely makes vanilla Rails seem like hard work. > > I was wondering if there are plans to extend the rich fields system. I > see at present it supports validation and representation to HTML but > it doesn't seem to support conversion for storage. > > An example would be currency. I want to store an amount of money in > cents but allow it to be entered and display it in a (culturally > insensitive) dollars.cents format. I can convert it in the model by > overriding the attribute accessors for it: > > fields do > price :integer > end > > def price() self[:price].as_dollars_and_cents; end > def price=(dollars) self[:price]=convert_to_cents(dollars); end > > By writing a Rails initializer (http://pastie.org/504098), I can get > it down to: > > fields do > price :integer > end > > treat_as_currency :price > > But what would be really cool would be to get it down to: > > fields do > price :currency > end > > Any thoughts on how/whether this could/should be achieved? > > Thanks > Ritchie > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/hobousers?hl=en -~----------~----~----~----~------~----~------~--~---
