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. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Help!!! Please!!! :( --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 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 -~----------~----~----~----~------~----~------~--~---
On Wednesday 13 September 2006 23:16, Michael Schuerig 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 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 -~----------~----~----~----~------~----~------~--~---
sw0rdfish wrote:> Is there a way to have a model''s variable set using multiople text_fieldsUse ActiveRecord''s before_create method in your model to combine two integer values into a single time property. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 :) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---