# Trying to learn if params can be modified

**URL:** <https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041>\
**Category:** Rails\
**Created:** [October 10, 2009, 9:32am UTC](https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041 "2009-10-10T09:32:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 10, 2009, 9:32am UTC](https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041/1 "2009-10-10T09:32:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 10, 2009, 10:17am UTC](https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041/2 "2009-10-10T10:17:50Z")

</div>

Bob S. 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 Help

Just assign appropriately:  
params[:birth\_year] += 1900

> Thanks
> 
> Bob

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 10, 2009, 5:57pm UTC](https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041/3 "2009-10-10T17:57:03Z")

</div>

Philip H. 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](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![adistarmid](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/f14d63/32.png) [@adistarmid](https://www.ruby-forum.com/u/adistarmid)\
**Post date:** [October 10, 2009, 5:18pm UTC](https://www.ruby-forum.com/t/trying-to-learn-if-params-can-be-modified/177041/4 "2009-10-10T17:18:02Z")

</div>

> > 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 🙂
