In my application I have users that have a ‘last_login’ attribute. I’m
trying do a find for all users that have not logged in for over a
month but I’m having a little trouble figuring out how to do this with
activerecord. Does anyone know how to do this, or do I have to use SQL?
I’m
trying do a find for all users that have not logged in for over a
month but I’m having a little trouble figuring out how to do this with
activerecord.
sql version
sql = <<-SQL
select *
from users
where last_login < current_timestamp - interval ‘1 month’
SQL
users_on_vacation = Users.find_by_sql(sql)