20th
Aug
Acts as Paranoid not considering objects deleted? Check your timezones.
You need to be careful with Database timezones in rails 2.1 — by default, MySQL will use the same timezone as the host machine (probably local time), whereas rails sensibly assumes the databse uses UTC by default.A combination of British Summer Time, acts_as_paranoid and
"deleted_at = NOW()" can easily lead to objects hanging around when they should be deleted. Its easy to fix though (at least in MySQL). First make sure that MySQL knows about the available timezones. On most Linux systems, timezone information can be found at /usr/share/zoneinfo and MySQL comes with a handy tool to import this:mysql_tzinfo_to_sql /usr/share/zoneinfo/ | mysql -u root -p mysqlIt’s probably best to bundle this up into a rake / cap task, as you’ll need to do it for every environment you run under.
Now you need to make sure that MySQL (or at least the ActiveRecord connection) is using UTC. You can change this system-wide on startup of MySQL, but also on a conenction basis. Adding the following to a script in config/environments/initializers will make sure that we’re running in the right timezone:
ActiveRecord::Base.connection.execute("SET time_zone = 'UTC';")