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.navigations

Session.where(user_id: 12).all

Session.where(user_id: 12).last.navigations

will tells us which user updated account with id 8

TODO

  • Mongoid ORM support

Contributing

  1. Fork it

  2. Create your feature branch (‘git checkout -b my-new-feature`)

  3. Commit your changes (‘git commit -am ’Added some feature’‘)

  4. Push to the branch (‘git push origin my-new-feature`)

  5. Create new Pull Request