Hi, I''ve got what seems to be a pretty simple problem. I can''t seem to get the values from a select_time into my database TIME field correctly. What''s the proper way to take the hour and minute hash, and prepare it correctly for saving? I imagine it is something very straightforward. I''m currently trying something probably pretty silly: @event = Event.new(@params[:event]) @event.start = @params[:start].values.join(":") + ":00" @event.finish = @params[:finish].values.join(":") + ":00" I''ve also tried just throwing Rails the hash''s to see if it would handle it automatically like it does with date_selects... that didn''t work of course! :) James
I got annoyed with how that and a couple other parts of the date helper work and submitted a patch that creates a time_select that works just like the date_select in terms of handling. ( Patch also fixed a couple bugs ) I have it as a lib that you could just install and use it that patch gets incorporated... If you want, contact me off list and I''ll send it to you. James Earl wrote:>Hi, > >I''ve got what seems to be a pretty simple problem. I can''t seem to get >the values from a select_time into my database TIME field correctly. > >What''s the proper way to take the hour and minute hash, and prepare it >correctly for saving? I imagine it is something very straightforward. >I''m currently trying something probably pretty silly: > >@event = Event.new(@params[:event]) >@event.start = @params[:start].values.join(":") + ":00" >@event.finish = @params[:finish].values.join(":") + ":00" > >I''ve also tried just throwing Rails the hash''s to see if it would handle >it automatically like it does with date_selects... that didn''t work of >course! :) > >James > > > >_______________________________________________ >Rails mailing list >Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >http://lists.rubyonrails.org/mailman/listinfo/rails > > >_______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks for the response Sean. I would like to see the patch that you''ve done. I did get things partially working using time_select: t = Time.new @event = Event.new(@params[:event]) @event.start = Time.local(t.year, t.mon, t.day, @params[:start][:hour], @params[:start][:minute]) @event.finish = Time.local(t.year, t.mon, t.day,@params[:finish][:hour], @params[:finish][:minute]) @event.save But this still doesn''t address time_select not setting the selected="" value when editing an existing record.> From: Sean T Allen <sean-5W9FBhQXBOtBDgjK7y7TUQ@public.gmane.org> > I got annoyed with how that and a couple other parts of the date helper work > and submitted a patch that creates a time_select that works just like > the date_select > in terms of handling. ( Patch also fixed a couple bugs ) > > I have it as a lib that you could just install and use it that patch > gets incorporated... > > If you want, contact me off list and I''ll send it to you. > > James Earl wrote: > > >Hi, > > > >I''ve got what seems to be a pretty simple problem. I can''t seem to get > >the values from a select_time into my database TIME field correctly. > > > >What''s the proper way to take the hour and minute hash, and prepare it > >correctly for saving? I imagine it is something very straightforward. > >I''m currently trying something probably pretty silly: > > > >@event = Event.new(@params[:event]) > >@event.start = @params[:start].values.join(":") + ":00" > >@event.finish = @params[:finish].values.join(":") + ":00" > > > >I''ve also tried just throwing Rails the hash''s to see if it would handle > >it automatically like it does with date_selects... that didn''t work of > >course! :) > > > >James