https://github.com/patorash/acts_as_footprintable
Rails gem to allowing records to leave footprints
https://github.com/patorash/acts_as_footprintable
activerecord rails ruby
Last synced: 11 months ago
JSON representation
Rails gem to allowing records to leave footprints
- Host: GitHub
- URL: https://github.com/patorash/acts_as_footprintable
- Owner: patorash
- License: mit
- Created: 2013-09-30T09:20:14.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2025-06-19T04:43:17.000Z (about 1 year ago)
- Last Synced: 2025-06-19T05:34:58.899Z (about 1 year ago)
- Topics: activerecord, rails, ruby
- Language: Ruby
- Homepage:
- Size: 341 KB
- Stars: 2
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# ActsAsFootprintable
[](https://github.com/patorash/acts_as_footprintable/actions/workflows/test.yml)
Acts As Footprintable is a Ruby Gem specifically written for Rails/ActiveRecord models.
The main goals of this gem are:
- Allow any model to leave footprints
- Get access ranking for footprintable model
- Get access histories by footprinter model
## Installation
### Rails 5.x, 6.x and 7.0
Add this line to your application's Gemfile:
```ruby
gem 'acts_as_footprintable', '~> 0.6.0'
```
And then execute:
$ bundle install
Or install it yourself as:
$ gem install acts_as_footprintable
### Database Migrations
Acts As Footprintable uses a footprints table to store all footprints information.
To generate and run the migration just use.
$ rails generate acts_as_footprintable:migration
$ rake db:migrate
## Usage
### Footprintable models
```ruby
class Post < ActiveRecord::Base
acts_as_footprintable
end
@post = Post.create(name: 'my post!')
@post.leave_footprints @user
@post.footprints.size # => 1
```
### Footprintable model access ranking
```ruby
# Total access ranking
total_ranking = Post.access_ranking
# Span access ranking
monthly_ranking = Post.access_ranking(1.month.ago.beginning_of_month..1.month.ago.end_of_month)
# Limit access ranking
monthly_top10_ranking = Post.access_ranking(1.month.ago.beginning_of_month..1.month.ago.end_of_month, 10)
# => {footprintable_id => count, ...}
```
### Footprinter models
```ruby
class User < ActiveRecord::Base
acts_as_footprinter
end
@user.leave_footprints @post
@post.footprints.size # => 1
```
### Footprinter model access histories
```ruby
# Total access histories
total_access_histories = @user.access_histories
# Limited total access histories
total_access_histories = @user.access_histories(10)
# Post access histories
post_access_histories = @user.access_histories_for Post
# Limited Post access histories
post_access_histories = @user.access_histories_for(Post, 10)
```
## Testing
$ bundle exec rake
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request