{"id":15723685,"url":"https://github.com/isuke/has_logs","last_synced_at":"2026-02-18T16:31:56.226Z","repository":{"id":56876022,"uuid":"64076853","full_name":"isuke/has_logs","owner":"isuke","description":"Logging your ActiveRecord model, and supply useful methods.","archived":false,"fork":false,"pushed_at":"2018-05-18T13:56:22.000Z","size":18,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-26T05:34:46.410Z","etag":null,"topics":["activerecord-models","gem","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/has_logs","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isuke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-24T17:20:01.000Z","updated_at":"2017-10-31T07:26:56.000Z","dependencies_parsed_at":"2022-08-20T11:31:02.278Z","dependency_job_id":null,"html_url":"https://github.com/isuke/has_logs","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/isuke/has_logs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isuke%2Fhas_logs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isuke%2Fhas_logs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isuke%2Fhas_logs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isuke%2Fhas_logs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isuke","download_url":"https://codeload.github.com/isuke/has_logs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isuke%2Fhas_logs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29585549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-18T13:56:48.962Z","status":"ssl_error","status_checked_at":"2026-02-18T13:54:34.145Z","response_time":162,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord-models","gem","ruby"],"created_at":"2024-10-03T22:12:49.919Z","updated_at":"2026-02-18T16:31:56.210Z","avatar_url":"https://github.com/isuke.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HasLogs\n\n[![Build Status](https://travis-ci.org/isuke/has_logs.svg?branch=master)](https://travis-ci.org/isuke/has_logs)\n\nLogging your ActiveRecord model, and supply useful methods.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'has_logs'\n```\n\nAnd then execute:\n\n```\n$ bundle\n```\n\nOr install it yourself as:\n\n```\n$ gem install has_logs\n```\n\n## Basic Example\n\n### First Migration\n\n```ruby\nclass CreateAllTables \u003c ActiveRecord::Migration\n  def self.up\n    create_table(:articles) do |t|\n      t.timestamps\n    end\n\n    create_table(:article_logs) do |t|\n      t.integer :article_id, null: false\n      t.string :title, null: false\n      t.text :content\n      t.boolean :public, null: false, default: true\n      t.datetime :created_at\n    end\n    add_index :article_logs,  :article_id\n    add_index :article_logs, [:article_id, :created_at], unique: true\n  end\nend\n```\n\n### Model Class\n\n```ruby\nclass Article \u003c ActiveRecord::Base\n  has_logs\nend\n\nclass ArticleLog \u003c ActiveRecord::Base\n  act_as_log\nend\n```\n\n### Usage Examples\n\n```ruby\narticle = Article.create(title: 'test1', content: 'demo1', public: false)\narticle.attributes =   { title: 'test2', content: 'demo2', public: false } ; article.save!\narticle.attributes =   { title: 'test3', content: 'demo3', public: true  } ; article.save!\n\narticle.title\n=\u003e 'test3'\n\narticle.logs\n=\u003e [#\u003cArticleLog id: 1, article_id: 1, title: \"test1\", content: \"demo1\", created_at: \"2015-01-04 03:36:51\"\u003e,\n #\u003cArticleLog id: 2, article_id: 1, title: \"test2\", content: \"demo2\", created_at: \"2015-01-04 03:36:51\"\u003e,\n #\u003cArticleLog id: 3, article_id: 1, title: \"test3\", content: \"demo3\", created_at: \"2015-01-04 03:36:51\"\u003e]\n\narticle.oldest_log\n=\u003e #\u003cArticleLog id: 1, article_id: 1, title: \"test1\", content: \"demo1\", created_at: \"2015-01-04 03:36:51\"\u003e\n\narticle.latest_log\n=\u003e #\u003cArticleLog id: 3, article_id: 1, title: \"test3\", content: \"demo3\", created_at: \"2015-01-04 03:36:51\"\u003e\n\narticle.oldest_log.next\n=\u003e #\u003cArticleLog id: 2, article_id: 1, title: \"test2\", content: \"demo2\", created_at: \"2015-01-04 03:36:51\"\u003e\n\narticle.latest_log.prev\n=\u003e #\u003cArticleLog id: 2, article_id: 1, title: \"test2\", content: \"demo2\", created_at: \"2015-01-04 03:36:51\"\u003e\n```\n\n#### Originator Methods\n\n| Methods       | Describe            |\n| ------------- | ------------------- |\n| logs          | get the log list    |\n| latest_log    | get the latest log  |\n| oldest_log    | get the oldest log  |\n\n#### Log Methods\n\n| Methods       | Describe                 |\n| ------------- | ------------------------ |\n| originator    | get the originator model |\n| next          | get a next log           |\n| prev          | get a prev log           |\n\n## Other Naming Example\n\n### Migration\n\n```ruby\nclass CreateAllTables \u003c ActiveRecord::Migration\n  def self.up\n    create_table(:users) do |t|\n      t.timestamps\n    end\n\n    create_table(:user_histories) do |t|\n      t.integer :user_id, null: false\n      t.string :name, null: false\n      t.datetime :created_at\n    end\n    add_index :user_logs,  :user_id\n    add_index :user_logs, [:user_id, :created_at], unique: true\n  end\nend\n```\n\n### Model Class\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  has_logs_as 'UserHistory'\nend\n\nclass UserHistory \u003c ActiveRecord::Base\n  act_as_log_of 'User'\nend\n```\n\n## Duplicate Type Example\n\n### Migration\n\n```ruby\nclass CreateAllTables \u003c ActiveRecord::Migration\n  def self.up\n    create_table(:tasks) do |t|\n      t.string :name, null: false\n      t.timestamps\n    end\n    create_table(:task_logs) do |t|\n      t.integer :task_id, null: false\n      t.string :name, null: false\n      t.datetime :created_at\n    end\n    add_index :task_logs,  :task_id\n    add_index :task_logs, [:task_id, :created_at], unique: true\n  end\nend\n```\n\n### Model Class\n\n```ruby\nclass Task \u003c ActiveRecord::Base\n  has_logs have_type: :duplicate\nend\nclass TaskLog \u003c ActiveRecord::Base\n  act_as_log\nend\n```\n\n### Usage Examples\n\n```\ntask  = Task.create(name: 'name1')\ntask.attributes = { name: 'name2' } ; task.save!\ntask.attributes = { name: 'name3' } ; task.save!\n\nTask.all\n=\u003e\n+----+-------+\n| id | name  |\n+----+-------+\n|  1 | name3 |\n+----+-------+\n\nTaskLog.all\n=\u003e\n+----+---------+-------+\n| id | task_id | name  |\n+----+---------+-------+\n|  1 |       1 | name1 |\n|  2 |       1 | name2 |\n|  3 |       1 | name3 |\n+----+---------+-------+\n```\n\n## Mutual Type Example\n\n### Migration\n\n```ruby\nclass CreateAllTables \u003c ActiveRecord::Migration\n  def self.up\n    create_table(:posts) do |t|\n      t.string :name, null: false\n      t.timestamps\n    end\n    create_table(:post_logs) do |t|\n      t.integer :post_id, null: false\n      t.string :name, null: false\n      t.datetime :created_at\n    end\n    add_index :post_logs,  :post_id\n    add_index :post_logs, [:post_id, :created_at], unique: true\n  end\nend\n```\n\n### Model Class\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  has_logs have_type: :mutual\nend\nclass PostLog \u003c ActiveRecord::Base\n  act_as_log\nend\n```\n\n### Usage Examples\n\n```\npost  = Post.create(name: 'name1')\npost.attributes = { name: 'name2' } ; post.save!\npost.attributes = { name: 'name3' } ; post.save!\n\nPost.all\n=\u003e\n+----+-------+\n| id | name  |\n+----+-------+\n|  1 | name3 |\n+----+-------+\n\nPostLog.all\n=\u003e\n+----+---------+-------+\n| id | post_id | name  |\n+----+---------+-------+\n|  1 |       1 | name1 |\n|  2 |       1 | name2 |\n+----+---------+-------+\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/isuke/has_logs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisuke%2Fhas_logs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisuke%2Fhas_logs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisuke%2Fhas_logs/lists"}