Ruby-on-rails – How to view users’ live events in Rails 3?

What I want to do is to allow my admin users to see in real time (through some AJAX/jQuery benefits) – what my users are doing.

What should I do?

I think it has something to do with the session activity-I have started to save the session to a database, not a cookie.

But in general, how do I get this information and parse it in real time?

I checked my session table, and besides id (id and session_id), I saw a’data’ field. The data field stores a hash-I can’t understand it (it looks like md5 Hash).

How can I use it to see that user A just clicked on link B, and then user B clicked on link A, etc.?

Are there any gems-besides rackamole-that might be able to help me?

The session data only contains the value stored in the session[]-the hash from the user. It Called actions/controllers are not stored, so you don’t know which “link was clicked”.

Get user activity:

In addition to rackamole, you have two choices. I’m blunt.

>Use before_filter in ApplicationController to store the relevant information you are interested in. (For example, controller name, operation or URI, additional parameters and the ID of the logged-in user).
>in Use AJAX calls at the bottom of each page to send the information you are interested in (URI, ID of the logged-in user, etc.) back to the server. This can shorten the server’s response time because the information is stored after the page is transferred. In addition, you don’t have to Use Rails requests to store it. AJAX requests can also call a simple PHP script to write data to disk. This is much faster.

Store this activity:

This data /Information is stored in a database or log file. The database will provide more flexibility, such as displaying all operations from a user, or displaying all visitors of a page, etc. The log file solution will provide you with better performance.

Real-time vs. Oldschool:

As for extracting collected data in real-time, you have to build your own solution. To do this elegantly (no need to query the server every second to view new data Has it arrived), you will need another server process. Search for AJAX Push for more information.

According to your application, I will ask myself whether you really need real-time notification (because of setting it up All troubles).

To monitor the activities on the site, there should be enough pages to list the latest operations and refresh manually (or automatically refresh every ten seconds).

What I want to do is to allow my admin users to see in real time (through some AJAX/jQuery benefits) – what my users are doing.

How can I Do it?

I think it has something to do with the session activity-I have started to save the session to a database, not a cookie.

But in general, how do I get this information and parse it in real time?

I looked at my session table and in addition to id (id and session_id), I saw a’data’ field. The data field stores a hash-I can’t understand it (it looks like md5 Hash).

How can I use it to see that user A just clicked on link B, and then user B clicked on link A, etc.?

Are there any gems-besides rackamole-that might be able to help me?

The session data only contains the value stored in the session[]-a hash from the user. It does not store the called action/controller, so you don’t Know which “link was clicked”.

Get user activity:

In addition to rackamole you have two options IMHO.

>In Before_filter is used in ApplicationController to store the relevant information you are interested in. (For example, controller name, operation or URI, additional parameters and the ID of the logged-in user).
>Use AJAX calls at the bottom of each page to interest you The information (URI, ID of the logged-in user, etc.) is sent back to the server. This can shorten the server’s response time because the information is stored after the page is transferred. In addition, you don’t have to use Rails requests to store it. AJAX requests can also be called A simple PHP script writes data to disk. This is much faster.

Store this activity:

Store this data/information in a database or log file. The database will Provides more flexibility, such as displaying all operations from a user, or displaying all visitors of a page, etc. The log file solution will provide you with better performance.

Real-time and Oldschool:< /p>

As for extracting collected data in real time, you have to build your own solution. To do this gracefully (no need to query the server every second to see if new data has arrived), you will need another server process . Search for AJAX Push for more information.

According to your application, I will ask myself if I really need real-time notification (because of all the hassles of setting it up).

To To monitor the activities on the site, there should be enough pages to list the latest operations and refresh manually (or automatically refresh every ten seconds).

Leave a Comment

Your email address will not be published.