I am trying to allow the destruction of a record only if this record has been created within the last 30 minutes.
Then I retrieve the
date1 = 2016-09-21 19:44:52 +0200
date2 = 2016-09-21 17:23:16 UTC
.minutes is what makes the thing don't work. Remove it and it should work.
If you want to find the gap in minutes between to date you just have to substract them, divide the result per 60 and round it.
((date1 - date2) / 60).round
Hope it helped, happy ruby coding!