I have to imagine that when creating an account in Qaru, your IP address is stored in the database in the Users table. Then, when you visit the page on the site, the IP address is retrieved from the HTTP request, and the Users table looks for the corresponding IP address. If there is a match, then this user record is updated with a timestamp representing the last visit.
Of course, this approach assumes that visitors to your site have a fixed IP address, which may not be the case, especially for users with dial-up Internet access.
You can easily register the current IP address in the Rails model:
class SomeModel < ActiveRecord::Base def request=(request) self.ip_address = request.remote_ip
Then in the view helper you can do something like:
def last_seen "Seen
Alternatively, the site may issue a cookie containing the timestamp of the visit that the server will search for. If a cookie was found, the timestamp will be read and the time difference will be calculated. The problem with this approach is that it does not work if the user uses a different web browser or computer (or both).
source share