{"id":15430642,"url":"https://github.com/fteem/douglas","last_synced_at":"2026-04-20T23:31:57.145Z","repository":{"id":62557452,"uuid":"85758463","full_name":"fteem/douglas","owner":"fteem","description":"🕐 Douglas adds stamps to any ActiveRecord model","archived":false,"fork":false,"pushed_at":"2018-01-06T11:07:12.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-20T06:55:29.128Z","etag":null,"topics":["activerecord-models","rails","stamping"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/douglas","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/fteem.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":"2017-03-21T22:08:36.000Z","updated_at":"2018-01-07T20:07:40.000Z","dependencies_parsed_at":"2022-11-03T06:15:45.291Z","dependency_job_id":null,"html_url":"https://github.com/fteem/douglas","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fteem/douglas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fteem%2Fdouglas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fteem%2Fdouglas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fteem%2Fdouglas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fteem%2Fdouglas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fteem","download_url":"https://codeload.github.com/fteem/douglas/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fteem%2Fdouglas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32070627,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T21:26:33.338Z","status":"ssl_error","status_checked_at":"2026-04-20T21:26:22.081Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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","rails","stamping"],"created_at":"2024-10-01T18:17:49.134Z","updated_at":"2026-04-20T23:31:57.117Z","avatar_url":"https://github.com/fteem.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Douglas\n\n[![Active Development](https://img.shields.io/badge/Maintenance%20Level-Actively%20Developed-brightgreen.svg)](https://gist.github.com/cheerfulstoic/d107229326a01ff0f333a1d3476e068d)\n\n**Status: Rough edges are to be expected.**\n\nDouglas is a Ruby gem that adds the ability to easily add `created_by` and\n`updated_by` attributes to any ActiveRecord model.\nIt allows easy user-stamping for any Active Record model.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'douglas'\n```\n\nAnd then execute:\n\n    $ bundle\n\n\n## Usage\n\n### Built-in generator\n\nWhen added in a Rails application, Douglas adds a generator which enables the users\nto easily generate migrations which need to be stamped.\n\nTo generate these migrations, you can use Douglas' `table` generator:\n\n```\nrails generate douglas:table NAME\n```\n\nThis will generate a migration:\n\n```\ncreate  db/migrate/20170322225126_add_created_by_and_updated_by_to_\u003cmodel-name\u003e.rb\n```\n\nThe contents of this migration will be:\n\n```ruby\nclass AddCreatedByAndUpdatedByTo\u003cmodel-name\u003e \u003c ActiveRecord::Migration[5.0]\n  def change\n    add_column :\u003cmodel-name\u003e, :created_by, :integer, null: false\n    add_column :\u003cmodel-name\u003e, :updated_by, :integer, null: false\n\n    add_index :\u003cmodel-name\u003e, :created_by\n    add_index :\u003cmodel-name\u003e, :updated_by\n  end\nend\n```\n\n### Plug it into a controller\n\nIn your `ApplicationController` add a `before_action`:\n\n```ruby\nclass ApplicationController\n  before_action :set_douglas_the_stamper\nend\n```\n\nThis will enable `Douglas` to know the current user that peroforms the action (create/update) on an model object.\n\n### Use it in models\n\nIn the model (that you ran the generate task for), add this:\n\n```ruby\nclass User \u003c ApplicationRecord\n  has_stamps\nend\n```\n\nThis will populat the `created_by` and `updated_by` attributes accordintly. Under\nthe hood this injects callbacks that are executed before create and update.\n\n### Use it in console\n\nSince the `{created,updated}_by` columns cannot be `null` it means that the `Douglas.the_stamper` has to always be set to a value. This is normally done via the controller `before_filter` method, but in console you have to use the `Douglas.with_stamper` method. This method expects two arguments, an identifier of the user that does the action and a block. This means that the user will be logged as the person that has done the actions within the block.\n\nFor example:\n\n```\n\u003e\u003e Douglas.with_stamper(123) do\n?\u003e   p = Post.first\n\u003e\u003e   p.body = 'Lorem ipsum dolor sit amet''\n\u003e\u003e   p.save\n\u003e\u003e end\n```\n\nThe `Post` will be updated, and the `updated_by` attribute will be set to the first passed argument - `123`.\n\n## Progress\n\n- [x] Add migrations generator (https://github.com/fteem/douglas/pull/1)\n- [x] Find way to hijack `current_user` and store in `RequestStore`\n- [x] Find way to plug-in `Douglas` in model lifecycle\n- [ ] Improve README quality\n- [ ] Add tests\n- [ ] Make logged attribute (currently `id`) to be configurable\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/[USERNAME]/douglas. 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## Why Douglas?\n\nNamed after [Douglas \"Doug\" **Stamper**](http://house-of-cards.wikia.com/wiki/Doug_Stamper),\nPresident Frank Underwood's White House Chief of Staff and former director of strategy.\n\n![](http://thediscussion.net/main/wp-content/uploads/2014/08/Doug-n-Brick-S1.gif)\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%2Ffteem%2Fdouglas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffteem%2Fdouglas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffteem%2Fdouglas/lists"}