Right -- that's what I currently do. Seems like there should be a way to
get the string 'current_timestamp' passed through to the database
without it getting interpreted. Like a default value for string/text
columns (haven't played around with that yet).
Joe, the problem with what you are proposing is that the default option
in your migration actually sets the default on the database column.
This default value is never interpreted by ruby after you run migrate
-- it exists in the database table definition itself. I don't know of
any database that allows for a dynamic default value as you are
proposing. I'm most familiar with MySQL ... maybe you can set the
default to the MySQL function NOW() ... but I don't know if that would
work, and it ceratinly wouldn't work if you ever deployed your app on
another database type. Try it, I'd be interested to see how it works.
I'm pretty sure that the best way to do this is with before_create or
magic columns as was already said.
Right -- that's what I currently do. Seems like there should be a way to
get the string 'current_timestamp' passed through to the database
without it getting interpreted. Like a default value for string/text
columns (haven't played around with that yet).
Joe, the problem with what you are proposing is that the default option
in your migration actually sets the default on the database column.
This default value is never interpreted by ruby after you run migrate
-- it exists in the database table definition itself. I don't know of
any database that allows for a dynamic default value as you are
proposing.