Craig W. wrote:
On Mon, 2006-01-30 at 17:54 +0100, Fred Wittekind wrote:
I’m trying to figure out the rails why to break a single database field
out into multiple fields on a form, very similar to how rails does with
dates. How can I create my own object that mirrors the date objects
behaviur in how it accepts the multiparameter assignment from the form.
A phone number field (to force formating on the user) could be broken
into 3 form fields, formated server side, and written to the database in
a single field.
there are helpers for phone numbers…
<%= number_to_phone(212-555-1212) %>
For what I’m trying to do, I need a form phone number helper, that
displays 3 text enty fields. I think I can write this helper though, if
I can figure out the rest of this.
there are validation methods such as validates_format_of attr, :with =>
regexp (pages 266 - 274 of Agile book)
I’m sure I will have to address validation, but not ready for that yet.
there is also a section on ‘aggregation’ in Agile book that discusses
handling/joining/separating strings (pages 257 - 263)
I’ve looked at the section on aggregation, and tried very unsuccessfully
at doing this with a composed_of aggregation. I got as far as the form
helper working, but as soon as I hit submit, it got a multiparameter
assignment error. It looked like ActiveRecord couldn’t figure out where
the object used in the aggregation was defined.