Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Update Rather Than Save? #8

Open
philnorton opened this issue Nov 8, 2017 · 3 comments
Open

Use Update Rather Than Save? #8

philnorton opened this issue Nov 8, 2017 · 3 comments

Comments

@philnorton
Copy link

Hey

Just a query ref:

def stamp!
if self.last_seen.to_i < (Time.now - 5.minutes).to_i
self.last_seen = DateTime.now
self.save!
end
end

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 
@ctide
Copy link
Owner

ctide commented Nov 9, 2017

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.

@shlima
Copy link

shlima commented Jan 25, 2018

+1

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

@shlima
Copy link

shlima commented Jan 25, 2018

  • DeviceLastseenable.config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants