# Hidden fields

**URL:** <https://www.ruby-forum.com/t/hidden-fields/83085>\
**Category:** Rails\
**Created:** [March 17, 2006, 11:29am UTC](https://www.ruby-forum.com/t/hidden-fields/83085 "2006-03-17T11:29:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antonin\_AMAND](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Antonin\_AMAND](https://www.ruby-forum.com/u/Antonin_AMAND)\
**Post date:** [March 17, 2006, 11:29am UTC](https://www.ruby-forum.com/t/hidden-fields/83085/1 "2006-03-17T11:29:58Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Hi,

I’m a rails newbie trying to develop a blog application with rails. I’ve  
some troubles to find the best way of automaticly set a field value on  
update and creation of a blog item.

In fact my problem is very simple. I’ve a blog table with two column  
named create\_date an mod\_date. And I’d like :

1 - that create\_date is set on creation and is never modified after that  
2 - mod\_date is set on update

Pre-Thanks for help.

Antonin.

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.2.4 (Darwin)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFEGo7prvKyD2MLOwsRAvCtAKDP4+EBGg/H1mPjuJfUZBRDEw37aQCfexgO  
ahyZ1Iu//wqzd7iM4ctFGgU=  
=1icq  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Antonin\_AMAND](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Antonin\_AMAND](https://www.ruby-forum.com/u/Antonin_AMAND)\
**Post date:** [March 17, 2006, 11:33am UTC](https://www.ruby-forum.com/t/hidden-fields/83085/2 "2006-03-17T11:33:10Z")

</div>

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

---

<div class="post-metadata">

**Author:** ![Antonin\_AMAND](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Antonin\_AMAND](https://www.ruby-forum.com/u/Antonin_AMAND)\
**Post date:** [March 17, 2006, 11:54am UTC](https://www.ruby-forum.com/t/hidden-fields/83085/3 "2006-03-17T11:54:33Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Mats L. a écrit :

> > 1 - that create\_date is set on creation and is never modified after that  
> > and  
> > created\_at TIMESTAMP

Thank you for your quick answer.

I understand that all this is about naming conventions ??  
\_on make the column to be updated when modification is made  
\_at make the column to be set a creation time

Am i right ?

Also, what if i want some field to be set by some code but not by the  
user.  
I have a field ‘user\_id’, not yet a table representing the user. I’ve  
seen this is automatically not-displayed in the scaffold. But, how can I  
set it with some piece of code when the record is created ?

Antonin.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.2.4 (Darwin)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFEGpT9rvKyD2MLOwsRApYmAJ0V6KiKX5Ld2SLFH5SUqY95c+8VtACfVqNz  
tThBqpWrvu3tOpCZP3O7TtI=  
=YplM  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Antonin\_AMAND](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Antonin\_AMAND](https://www.ruby-forum.com/u/Antonin_AMAND)\
**Post date:** [March 17, 2006, 12:09pm UTC](https://www.ruby-forum.com/t/hidden-fields/83085/4 "2006-03-17T12:09:54Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Antonin AMAND a écrit :

> > > > 
> > > 
> > > modified\_on DATETIME  
> > > and  
> > > created\_at TIMESTAMP
> 
> Thank you for your quick answer.
> 
> I understand that all this is about naming conventions ??  
> \_on make the column to be updated when modification is made  
> \_at make the column to be set a creation time
> 
> Am i right ?

I’m not ! i’ve just try this, an it doesn’t do what i want. ☹  
modification an creation date can still be modified by the user.

Antonin.  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.2.4 (Darwin)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iD8DBQFEGph9rvKyD2MLOwsRAutMAJkBnW+UWvcgw5/wqfWnCuZSNV3kBgCgjKR2  
A7YmqrboAyS/wPrpmxBlau4=  
=cemZ  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Antonin\_AMAND](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Antonin\_AMAND](https://www.ruby-forum.com/u/Antonin_AMAND)\
**Post date:** [March 17, 2006, 12:22pm UTC](https://www.ruby-forum.com/t/hidden-fields/83085/5 "2006-03-17T12:22:11Z")

</div>

* * *

Rails mailing list  
removed\_email\_address@domain.invalid  
[http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)
