I just did raise params[:event].inspect and got {"change_mode_at(1i)"=>"2006", "change_mode_at(2i)"=>"8", "change_mode_at(3i)"=>"30", "change_mode_at(4i)"=>"19", "change_mode_at(5i)"=>"37", "change_mode_to"=>"0"} shouldn''t I have a change_mode_at with a time object? Because all I get is nil. Thanks for your help. -- 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 -~----------~----~----~----~------~----~------~--~---
Actually no. Rail''s HTML date helper methods puts this little paranthesees to group the seperate portions that make up a whole Time object. Notice that each of these controls represent parts of your time object. So you have a single object that is made up of a year-month-day hour:minute:second in your case (2006-8-30 19:37:00), but you can''t just use one HTML control to display it all so the framework developers have a mismatch between posted params and object layout. To fix this rails puts those parantheese to distinguish the parts that make up the whole. Usually this isn''t an issue unless you''re using these controls and splitting your values across multiple fields (i.e. no using a standard Time or Date object). Like credit_card[:expiration_month] and credit_card[:expiration_year] and you were using the date_select helper methods. You can work around this issue, but this doesn''t sound like what you''re doing. Check how you''re using the date_select controls and make sure you have the write name of your object''s field. Does your :event object have a member called :change_mode_at? If not that could be why you''re getting nil in the event object you construct. Charlie Ben Johnson wrote:> I just did > > raise params[:event].inspect > > and got > > {"change_mode_at(1i)"=>"2006", "change_mode_at(2i)"=>"8", > "change_mode_at(3i)"=>"30", "change_mode_at(4i)"=>"19", > "change_mode_at(5i)"=>"37", "change_mode_to"=>"0"} > > shouldn''t I have a change_mode_at with a time object? Because all I get > is nil. > > Thanks for your help.-- 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 -~----------~----~----~----~------~----~------~--~---
Charlie Hubbard wrote:> > Actually no. Rail''s HTML date helper methods puts this little > paranthesees to group the seperate portions that make up a whole Time > object. Notice that each of these controls represent parts of your time > object. So you have a single object that is made up of a year-month-day > hour:minute:second in your case (2006-8-30 19:37:00), but you can''t just > use one HTML control to display it all so the framework developers have > a mismatch between posted params and object layout. > > To fix this rails puts those parantheese to distinguish the parts that > make up the whole. Usually this isn''t an issue unless you''re using > these controls and splitting your values across multiple fields (i.e. no > using a standard Time or Date object). Like > credit_card[:expiration_month] and credit_card[:expiration_year] and you > were using the date_select helper methods. You can work around this > issue, but this doesn''t sound like what you''re doing. > > Check how you''re using the date_select controls and make sure you have > the write name of your object''s field. Does your :event object have a > member called :change_mode_at? If not that could be why you''re getting > nil in the event object you construct. > > Charlie.Yes my events table has a field called change_mode_at and it is a datetime field. How can I turn this group into a datetime object? -- 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 -~----------~----~----~----~------~----~------~--~---
Ben Johnson wrote:> Yes my events table has a field called change_mode_at and it is a > datetime field. How can I turn this group into a datetime object?It works with mass assignment but not individual assignment. So this won''t work Event.new(:change_mode_at => params[:event][:change_mode_at]) but this will Event.new(params[:event]) Active record senses all the components of the date or time fields and zips them together. --- This has always bothered me. Wouldn''t it be possible for rails to sense this are renconstruct the params so it includes a Time object? Seems like that would be much cleaner. -- 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 -~----------~----~----~----~------~----~------~--~---