If I have a form similar to the one below, and ''start'' is a "string" field in my Database. Is there a way to take all of the date/time params and put them into ''start'' without too much hacking? I would like this to be as clean as possible. <p><label for="start_time">Start Time</label><br/> <%= form.datetime_select ''start'' %></p> To clarify, when "new" is called, my rails app does the standard: @period = Period.new(params[:whatever]) I''d rather not break that apart if possible. Please let me know if this doesn''t make sense. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
I don''t know if I understand you correctly, but it sounds like you are concerned that the datetime select is split into multiple selection lists and you want the date stored as one attribute in the database. If this is the case, rails should automatically ''fuse'' all the parameters into one datetime value as long as your column is set to datetime and not string. On Dec 12, 3:37 pm, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If I have a form similar to the one below, and ''start'' is a "string" > field in my Database. Is there a way to take all of the date/time > params and put them into ''start'' without too much hacking? I would > like this to be as clean as possible. > > <p><label for="start_time">Start Time</label><br/> > <%= form.datetime_select ''start'' %></p> > > To clarify, when "new" is called, my rails app does the standard: > @period = Period.new(params[:whatever]) > > I''d rather not break that apart if possible. Please let me know if > this doesn''t make > sense. > > Thanks!--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
You got it exactly, however I modified the column attribute to datetime and simply passing it back, I get an error: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.inject On Dec 12, 2:14 pm, ebrad <nisguy_...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:> I don''t know if I understand you correctly, but it sounds like you are > concerned that the datetime select is split into multiple selection > lists and you want the date stored as one attribute in the database. > > If this is the case, rails should automatically ''fuse'' all the > parameters into one datetime value as long as your column is set to > datetime and not string. > > On Dec 12, 3:37 pm, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > If I have a form similar to the one below, and ''start'' is a "string" > > field in my Database. Is there a way to take all of the date/time > > params and put them into ''start'' without too much hacking? I would > > like this to be as clean as possible. > > > <p><label for="start_time">Start Time</label><br/> > > <%= form.datetime_select ''start'' %></p> > > > To clarify, when "new" is called, my rails app does the standard: > > @period = Period.new(params[:whatever]) > > > I''d rather not break that apart if possible. Please let me know if > > this doesn''t make > > sense. > > > Thanks!--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Nevermind, that worked perfectly. Thank you! On Dec 12, 2:21 pm, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You got it exactly, however I modified the column attribute to > datetime and simply passing it back, I get an error: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.inject > > On Dec 12, 2:14 pm, ebrad <nisguy_...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote: > > > I don''t know if I understand you correctly, but it sounds like you are > > concerned that the datetime select is split into multiple selection > > lists and you want the date stored as one attribute in the database. > > > If this is the case, rails should automatically ''fuse'' all the > > parameters into one datetime value as long as your column is set to > > datetime and not string. > > > On Dec 12, 3:37 pm, pete <peterbattag...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > If I have a form similar to the one below, and ''start'' is a "string" > > > field in my Database. Is there a way to take all of the date/time > > > params and put them into ''start'' without too much hacking? I would > > > like this to be as clean as possible. > > > > <p><label for="start_time">Start Time</label><br/> > > > <%= form.datetime_select ''start'' %></p> > > > > To clarify, when "new" is called, my rails app does the standard: > > > @period = Period.new(params[:whatever]) > > > > I''d rather not break that apart if possible. Please let me know if > > > this doesn''t make > > > sense. > > > > Thanks!--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---