postgresql - Rails: Compare DateTime with Time.now -
i'm sure super easy reason can't it. i'm using psql , devise. have user model has expiration column. i'm trying is, when use logs in, have devise include check expiration well.
i've overridden active_for_authentication? method in model this:
def active_for_authentication? super && expiration > time.now.to_s(:db) end but it's letting in...
help me stackoverflow, you're hope!
edit i'm setting expiration before update amount dynamic variable:
self.expiration = amount.weeks.from_now edit 2 rails console says this:
#<user:xxx> {:expiration => mon, 24 mar 2014 19:19:42 utc +00:00}
2.0.0p0 :013 > time.now 2014-03-24 13:10:47 -0700
obviously different, why assume aren't working. i'm trying find out if there simple conversion i'm missing e.g.: .to_s(:db) or if have kind of string compare.
don't compare strings, let compare on time.
def active_for_authentication? super && expiration.to_time > time.now end
Comments
Post a Comment