Hi all, Rails 2.1 seems to converts the following parameters {''birth(1i)''=''1990'', ''birth(2i)''=>''2'', ''birth(3i)''=>''31''} into date ''1990-03-02'' automatically. Is it able to inhibit this convertion? -- makoto kuata --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Does anyone help me? The following is an example to be converted invalid date automatically (2008-02-31 -> 2008-03-02). I want to stop this convertion. $ ruby script/generate scaffold person name:string birth:date $ rake db:migrate $ ruby script/console>> hash = {"name"=>"Foo", "birth(1i)"=>"2008", "birth(2i)"=>"2", "birth(3i)"=>"31"} >> person = Person.new(hash) >> p person#<Person id: nil, name: "Foo", birth: "2008-03-02", created_at: nil, updated_at: nil> -- makoto kuwata On Jun 13, 7:04 pm, makoto kuwata <kwa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Rails 2.1 seems to converts the following parameters > {''birth(1i)''=''1990'', ''birth(2i)''=>''2'', ''birth(3i)''=>''31''} > into date ''1990-03-02'' automatically. > Is it able to inhibit this convertion? > > -- > makoto kuata--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
makoto kuwata wrote:> Does anyone help me? > The following is an example to be converted invalid > date automatically (2008-02-31 -> 2008-03-02). > I want to stop this convertion. > > $ ruby script/generate scaffold person name:string birth:date > $ rake db:migrate > $ ruby script/console >>> hash = {"name"=>"Foo", "birth(1i)"=>"2008", "birth(2i)"=>"2", "birth(3i)"=>"31"} >>> person = Person.new(hash) >>> p person > #<Person id: nil, name: "Foo", birth: "2008-03-02", created_at: nil, > updated_at: nil> > > -- > makoto kuwataThere is no February 31, 2008 (2008-02-31). This year, 2008, is a leap year so there WAS a February 29, 2008. The next day would be March 1, 2008 (February 30, 2008 by your calendar) and the day after March 2, 2008 (2008-03-02) or February 31, 2008 on your calendar. So Rails/Ruby "fixed" it for you. If you don''t want that behaviour, use strings for you special two extra days in February. (What are you gong to do next year without February 29, 2009? :) CEO Summary: ROR got your back! -- 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?hl=en -~----------~----~----~----~------~----~------~--~---