What I am trying to do is have the user enter a 2 digit birth year in the view, then have the controller do it''s magic and get a 4 digit date for the birthday. That part went fine, but now I''m having trouble replacing the 2 digit year in params with the correct 4 digit value before the create/update to the database. Please Help Thanks Bob
Bob Smith wrote:> What I am trying to do is have the user enter a 2 digit birth year in > the view, then have the controller do it''s magic and get a 4 digit > date for the birthday.That should probably be done in the model, not the controller.> That part went fine, but now I''m having trouble > replacing the 2 digit year in params with the correct 4 digit value > before the create/update to the database. Please HelpJust assign appropriately: params[:birth_year] += 1900> > Thanks > > BobBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.
>> That part went fine, but now I''m having trouble >> replacing the 2 digit year in params with the correct 4 digit value >> before the create/update to the database. Please Help > > Just assign appropriately: > params[:birth_year] += 1900Careful. My kid was born in 2004... not 1904. He probably won''t be signing up on your website, but then again he recently admonished me for not knowing about youtube playlists so you never know. Better to check the 2 digits... if it''s less than 09 add 2000. Otherwise add 1900. Of course that will tick off all your 100-yr old users :)
Philip Hallstrom wrote:>>> That part went fine, but now I''m having trouble >>> replacing the 2 digit year in params with the correct 4 digit value >>> before the create/update to the database. Please Help >> >> Just assign appropriately: >> params[:birth_year] += 1900 > > Careful. My kid was born in 2004... not 1904. He probably won''t be > signing up on your website, but then again he recently admonished me > for not knowing about youtube playlists so you never know. > > Better to check the 2 digits... if it''s less than 09 add 2000. > Otherwise add 1900. Of course that will tick off all your 100-yr old > users :)I''m aware of that, of course. This was meant to be a rudimentary example, but thanks for stating explicitly what I was too lazy to! :) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/.