I have an attribute for my users called :last_request_at, :null => false
I need to set this attribute to the current time on sign up / create. But I don’t know how?
a hidden field in the sign up form maybe? If yes how would that look like? Or how does Devise set his trackable attributes on signup/create to the current time?
EDIT
I put this in the user model:
before_save :set_last_request
def set_last_request
self.update_attribute(:last_request_at, Time.now)
end
but then I get:
stack level too deep
I would set the attribute in your controller action. Your stack level too deep error is because
update_attributecallssaveat the end. You are infinitely callingset_last_request.I would just call
@record.last_request_at = Time.nowin your controller action, or modify your before_save hook to just doself.last_request_at = Time.now.