Track a user who has updated data in Ruby on Rails - ruby-on-rails

I am new to Ruby on Rails. The rails application that I have developed has several models including one for user that stores user name, passwords and other user related information.
Now the problem is that a few columns of a table corresponding to a model has modified erratically. Now I want to know if Ralis has any feature so that I can know the user who has done this or this is because of some other reasons.

You can try installing Userstamp and maybe Paper Trail to track changes to records. If you've implemented the User model yourself (as opposed to a framework like devise), you'll need to read the docs carefully to see what properties are expected of your User models to get the full benefit.

Using devise
It adds other columns(yours) in migrate, before generate views

https://github.com/collectiveidea/audited might provide the auditing you require.

Related

Using the gem paper_trail for tracking the latest news-activity on my website

I'm using the gem paper_trail for keeping track of versions. I wonder, is there any way to create some kind of activity news out of the models it's been included into? For example, I've added it into the models Commentary, User and Article. I want to be to get a list of the latest changes of these models and create something like news of activities:
user A has created a new Category
user B has edited an Article
admin had added a new Article
etc
Is it possible? And how? Seems like yes, but how exactly? Note that, I don't want to retrieve that kind of information from all the models I've included the gem into, but only from the ones I want to.
Since you want it by the user, you should integrate https://github.com/ankit1910/paper_trail-globalid to link the whodunnit part.
PaperTrail::Version.where_object(attr1: val1, attr2: val2)
NOTE: paper_trail gem is for auditing.
Do not forget to check your indexes on your database since relational databases slow as your no. of indexes increase.
Based on my experience with [spree][1] framework and a similar gem, versions table was the largest we had and it grew quiet fast. You may face similar challenges in maintaining this table and adding indexes may cause it to slow down.
My suggestion would be to use a Redis like store to maintain a list of 10 or so recent updates per user which the user may be notified of instead of querying MySQL (essentially caching)

Ruby on Rails -- How to create table of ALL logins/sessions

I have a working application for using Devise for user models and authentication. I want to create a table that effectively stores ALL the logins a user ever has, and the length of these sessions. I do not need to store session data with the entries. Am using the "timeoutable" option in Devise which I think will ensure I always have a logout time (?) even if a user just closes the browser window.
What I want is effectively the opposite (in some sense) of how the sessions table operates in only recording the latest user session when using active_record_store option in config/initializers/session_store.rb
So what's needed is a logins table with user_id and login_id/index (plus login time and logout time) that is edited automatically any time a user logs in or out, and DOESN'T delete or overwrite the older sessions. Does this require a model, controller, etc. like other user-edited objects?
Answer is probably something simple, but I spent a lot of time looking and didn't see too many folks who actively want to store MORE user data like this. Thanks for any advice! [I'm a Prof. doing this for a basic web-course app so I can make student time on the site part a factor in their grade ;)]
Using rails 3.2.13, devise, sqlite3 for development db
If you don't want to reinvent the wheel, you can have a look at those 2 gems. They offer model data change tracking:
https://github.com/airblade/paper_trail
https://github.com/collectiveidea/audited

working with a database record without saving it in rails

I am developing an application using ruby on Rails that is going to be used to train learners in high fidelity simulations in which they need to record notes in an web based electronic record-keeping system.
The idea is to be able to allow users to retrieve a simulated record from the database, interact with it by adding child records that represent procedure notes, messages to other people and the like, and at the end of the session display the changes and additions that were made. After all of that the "template" record will need to be able to be reset to its original state, returning to the state it was in before the user worked with it.
Multiple users will use the same "template" record in different simulation rooms, so changes made by one user should not affect the data available to other users.
I have already developed much of the application using generated scaffolding that I have modified to produce the basic functionality of the record system.
Now I need to figure out the "simulation mode" functionality which allows a user to "tear off" a copy of a record that will be thrown away after changes are made at the end of a session.
Has anyone developed a rails application that has similar requirements to those I listed above?
I am thinking I will need to store copies of the patient and its child objects in session variables. Are there any examples available to that show how to store copies of objects in session variables and modify and add to those objects using forms? Any help and advice would be very appreciated.
I think what you are looking for is version management. There are a number of gems to do this, I suggest looking at:
http://railscasts.com/episodes/255-undo-with-paper-trail
...and see if the kind of functionality can be addressed with paper trail. If not, checkout:
https://www.ruby-toolbox.com/categories/Active_Record_Versioning
https://github.com/collectiveidea/audited
very cool gem, you simply store the audit state in session to which you then roll back.

Log user activity gem

i am about to create the functionality for logging user activity in my application. I was thinking of using observers and then log events through another model, something like UserLog.
Before doing that though, i would like to ask if there is already a good gem out there than can save me some time on this.
Do you happen to know any ?
p.s. btw, i am talking about custom defined user activity as well as logging ip addresses and so on. The first case of custom actions logging is more important though.
edit for clarity: I'm not referring to model changes but logging posted form variables and actions like this, not model changes.
audited
audited is an ActiveRecord extension that logs all changes to your models in an audits table, with optional revision comments. acts_as_audited has been updated to work with Rails 3, to use it with older version of Rails .

Are there any authentication plugins that work with DataMapper?

I'm in need of an authentication method that works with DataMapper. I can see that the authlogic plugin requires the fields
crypted_password, password_salt, persistence_token
in the User model. Is it enough to just add these fields to the User model definition using DataMapper?
It would need to be significantly more sophisticated than that, since the APIs are quite different between DataMapper and ActiveRecord. However, it appears at least one person is on the same wavelength as you. Check out this ticket, which has a link to this pastie that integrates authlogic into a User model using DataMapper.
simplest_auth
is compatible with DataMapper

Resources