Ok this is probably a silly question, but I’ve been up all night, and
I’m not thinking right 
Is there a way to have a model’s variable set using multiople
text_fields, while still using the
<%= text_field :order, :time %> but have two text_fields for it, and
then
order.create(params[:order]) in the controller…
I know the date_select helper, creates parameters called date(1i),
date(2i), date(3i)… I guess I’m wondering if I can manually do the
same thing, for lets say “time” have a drop down for the hour, and
drop down for the minutes w/o having to then write manual code to set
the time…
I hope that makes sense.
On Wednesday 13 September 2006 16:14, sw0rdfish wrote:
I know the date_select helper, creates parameters called date(1i),
date(2i), date(3i)… I guess I’m wondering if I can manually do the
same thing, for lets say “time” have a drop down for the hour, and
drop down for the minutes w/o having to then write manual code to set
the time…
Yes, you can. If you need to know the details, have a look at the source
code of ActiveRecord::Base#assign_multiparameter_attributes and
following.
Basically, if you have an aggregation defined where the constructor of
the aggregate 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)>)
Michael
–
Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/
sw0rdfish wrote:
Is there a way to have a model’s variable set using multiople text_fields
Use ActiveRecord’s before_create method in your model to combine two
integer values into a single time property.
Forgot to thank you guys!
I haven’t had a chance to test it, I’ve been fixing some real sloppy
coding… but it makes perfect sense… I’ll report back incase somone
else cares 
On Wednesday 13 September 2006 23:16, Michael S. wrote:
Basically, if you have an aggregation defined where the constructor
of the aggregate class takes multiple arguments, …
Forget about aggregations. Yes, it works for them, of course, but the
point is really to supply the multiple arguments needed by the
constructor of a class-valued (i.e. not String, Fixnum and cousins)
attribute.
Michael
–
Michael S.
mailto:[email protected]
http://www.schuerig.de/michael/