devise_lastseenable icon indicating copy to clipboard operation
devise_lastseenable copied to clipboard

Use Update Rather Than Save?

Open philnorton opened this issue 8 years ago • 3 comments

Hey

Just a query ref: https://github.com/ctide/devise_lastseenable/blob/2fbfdc490e0a032d98070d6aae30bb332715b5a7/lib/devise_lastseenable/model.rb#L6-L11

This is causing validations (ie validates_presence_of) against the User model to fail when it's trying to perform the update for the last seen timestamp. Rather than saving here, can this not just make use of update_column so that validations etc aren't triggered?

def stamp! 
  self.update_column(:last_seen, DateTime.now) if self.last_seen.to_i < (Time.now - 5.minutes).to_i 
end 

philnorton avatar Nov 08 '17 15:11 philnorton

I know we made a similar update to this a while ago, and it broke due to another change, I believe, in that PR. Unfortunately, I haven't written any ruby code in years, and don't have any reasonable way to test/verify any changes so I'm reluctant to touch this thing.

I know it's not really a great response, but I'd recommend forking and just using your own version of it.

ctide avatar Nov 09 '17 00:11 ctide

+1

Could you please alse use Time.current instead of Time.now and move frequency tine (5 minutes) inside DeviceConfirable ?

shlima avatar Jan 25 '18 19:01 shlima

  • DeviceLastseenable.config

shlima avatar Jan 25 '18 19:01 shlima