On Saturday 07 October 2006 22:49, Bryan Duxbury wrote:> Does anyone know where to find information about making use of
> multi-paramter attributes (like dates) to make your own helpers?
Have a look at the source code of
ActiveRecord::Base#assign_multiparameter_attributes and following.
Basically, if you have a class-typed attribute (i.e
not :string, :integer and so on) where the constructor of the class
takes multiple arguments, you can indicate position and type of these
arguments in parentheses. In this way something(1i), something(2s),
something(3f) are mapped to
Something.new(
<fixnum-value-of-param-something(1i)>,
<string-value-of-param-something(2s)>,
<float-value-of-param-something(3f)>)
So, if you want to use this in a helper method, you just have to make
sure that it generates suitably named form elements
<input type="text" name="something(1i)" />
<input type="text" name="something(2s)" />
<input type="text" name="something(3f)" />
HTH,
Michael
--
Michael Schuerig
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org
http://www.schuerig.de/michael/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---