DeviseActivity
Keep history of user page views and time spent on differnt pages in rails. This gem depends on devise gem and uses devise ‘current_user’ helper method which can be configured.
Installation
Simply add trackstamps gem to your Gemfile.
gem 'devise-activity'
Install bundler gems
bundle install
Install trackstamps
rails generate devise_activity:install
You can change sessions and navigations table names from generated configuration file (config/initializers/devise_activity.rb) before generating migration. Generate migration on required model’s table
rails generate devise_activity:migration
Include DeviseActivity module to application controller or admin etc for which you want to track user activities
class ApplicationController
include DeviseActivity
.....
end
Execute migrations
rake db:migrate
And now you are ready to track changes
Usage
It will automatically keep of sign in’s, sign out’s and page views history in sessions and navigations table i.e.
Session.all
will return last account was created by which user. Similarily
Session.last.
Session.where(user_id: 12).all
Session.where(user_id: 12).last.
will tells us which user updated account with id 8
TODO
-
Mongoid ORM support
Contributing
-
Fork it
-
Create your feature branch (‘git checkout -b my-new-feature`)
-
Commit your changes (‘git commit -am ’Added some feature’‘)
-
Push to the branch (‘git push origin my-new-feature`)
-
Create new Pull Request