I have a delayed job working.
CarController.delay(run_at: 20.minutes.from_now).check_if_loggedin(@user)
def self.check_if_loggedin(user)
...
end
After 20 minutes, I want to remove user name from dom with jquery. But how can I do that after Delayed Job? Should I add respond to block ?
Neither jQuery, nor Rails can do this at their own.
You need to create a websocket connection so that Rails can inform jQuery to remove the particular user from DOM via a server push message.
Alternatively, you can ping the server using AJAX in a frequent interval and update the DOM if Rails asks you to do so.