Hidden fields

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

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


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

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

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

-----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. :frowning:
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

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


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails