{"id":13877928,"url":"https://github.com/keshavbiswa/active_record_anonymizer","last_synced_at":"2026-01-10T03:56:33.221Z","repository":{"id":226281340,"uuid":"731578169","full_name":"keshavbiswa/active_record_anonymizer","owner":"keshavbiswa","description":"A ruby gem to anonymize your ActiveRecord attributes with ease.","archived":false,"fork":false,"pushed_at":"2024-04-07T12:44:16.000Z","size":102,"stargazers_count":56,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-15T05:45:33.531Z","etag":null,"topics":["activerecord","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"","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/keshavbiswa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-12-14T11:50:39.000Z","updated_at":"2024-10-19T04:11:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"08bd55fb-d02a-4f15-93cd-efde5958906c","html_url":"https://github.com/keshavbiswa/active_record_anonymizer","commit_stats":null,"previous_names":["keshavbiswa/active_record_anonymizer"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Factive_record_anonymizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Factive_record_anonymizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Factive_record_anonymizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Factive_record_anonymizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keshavbiswa","download_url":"https://codeload.github.com/keshavbiswa/active_record_anonymizer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226134226,"owners_count":17578778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","ruby","ruby-on-rails"],"created_at":"2024-08-06T08:01:35.139Z","updated_at":"2026-01-10T03:56:33.153Z","avatar_url":"https://github.com/keshavbiswa.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# ActiveRecordAnonymizer\n\nAnonymize your ActiveRecord models with ease :sunglasses:\n\n`ActiveRecordAnonymizer` uses `faker` to anonymize your ActiveRecord model's attributes without the need to write custom anonymization logic for each model.\n\nUsing `ActiveRecordAnonymizer`, you can:\n- Anonymize specific attributes of your model (uses `faker` under the hood)\n- Provide custom anonymization logic for specific attributes\n- Provide custom anonymized columns for each attributes\n- Encrypt anonymized data using `ActiveRecord::Encryption` (Requires Rails 7+)\n- Environment dependent, so you can decide whether you want to view original data in development and anonymized data in production\n\n## Screencast\n\n[![Introducing ActiveRecordAnonymizer](https://img.youtube.com/vi/EcQHD33-P-g/0.jpg)](https://www.youtube.com/watch?v=EcQHD33-P-g)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'active_record_anonymizer'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n    \n    $ gem install active_record_anonymizer\n\nInstall the gem using the following command:\n\n    $ bin/rails generate active_record_anonymizer:install\n\nYou must have anonymized columns in your Model to store the anonymized data.\nYou can use the following migration generator to add anonymized columns to your existing table:\n\n    $ bin/rails generate active_record_anonymizer:anonymize User first_name last_name\nThis will generate a migration file similar to the following:\n\n```ruby\nclass AddAnonymizedColumnsToUser \u003c ActiveRecord::Migration[6.0]\n  def change\n    add_column :users, :anonymized_first_name, :string\n    add_column :users, :anonymized_last_name, :string\n  end\nend\n```\n\nAdd the following line to your model to enable anonymization:\n\n```ruby\nclass User \u003c ApplicationRecord\n  # There are other options available, please refer to the Usage section\n  anonymize :first_name, :last_name\nend\n```\nTo populate the anonymized columns, run the following command:\n\n    $ bin/rails anonymizer:populate CLASS=User\n\nThe `CLASS` argument is optional, if not provided, it will anonymize all the models with anonymized columns.\n\n## Usage\n\nAttributes can be anonymized using the `anonymize` method. The `anonymize` method takes the following options:\n\n- `:column_name` - The name of the column to store the anonymized data. (\"anonymized_#{column_name}\" by default)\n- `:with` - The custom logic to anonymize the attribute. (Optional, uses `faker` by default)\n- `:encrypt` - Encrypt the anonymized data using `ActiveRecord::Encryption` (Requires Rails 7+)\n\n```ruby\nclass User \u003c ApplicationRecord\n  anonymize :first_name, :last_name\n  anonymize :email, with: -\u003e(_record) { Faker::Internet.email }\n  anonymize :age, with: -\u003e(record) { record.age + 5 }\n  anonymize :phone, column_name: :fake_phone_number, with: -\u003e(record) { record.phone.gsub(/\\d/, 'X') }\n  anonymize :address, encrypt: true\nend\n```\n\n## Configuration\n\nYou can configure the gem using the following options:\n\n- `:environments` - The environments in which the anonymized data should be used. (Defaults to `[:development]`)\n- `:skip_update` - Skip updating the anonymized data when the record is updated. This ensures your anonymized data remains the same even if it's updated. (Defaults to `false`)\n- `:alias_original_columns` - Alias the original columns to the anonymized columns. You can still access the original value of the attribute using the alias `original_#{attribute_name}`(Defaults to `false`)\n- `:alias_column_name` - The name of the alias column. (Defaults to `original_#{column_name}`)\n\n```ruby\nActiveRecordAnonymizer.configure do |config|\n  config.environments = [:development, :staging] # The environments in which the anonymized data should be used\n  config.skip_update = true # Skip updating the anonymized data when the record is updated\n  config.alias_original_columns = true # Alias the original columns to the anonymized columns\n  config.alias_column_name = \"original\" # The original column will be aliased to \"original_#{column_name}\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\n Then, run `rake test` to run the tests.\n You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports are welcome on GitHub at https://github.com/keshavbiswa/active_record_anonymizer/issues.\n\n- Fork the Repository: Start by forking this [repo](https://github.com/keshavbiswa/active_record_anonymizer.git) on GitHub.\n\n- Set Up Your Local Environment: Navigate into the project directory and run the setup script to install dependencies:\n\n```shell\n    $ cd active_record_anonymizer\n    $ bin/setup\n```\n- Create a New Branch: Before making any changes, create a new branch to keep your work organized:\n\n```shell\n    $ git checkout -b my-new-feature\n```\n\n- Make Your Changes: \n  - Implement your changes or fixes in your local repository.\n  - Be sure to keep your changes as focused as possible. \n  - If you're working on multiple unrelated improvements, consider making separate branches and pull requests for each.\n\n- Write Tests: If you're adding a new feature or fixing a bug, please add or update the corresponding tests. \n\n- Run Tests: Before submitting your changes, run the test suite to ensure everything is working correctly:\n```shell\n    $ bin/rake test\n```\n\n- Update Documentation: If your changes involve user-facing features or APIs, update the README or other relevant documentation accordingly.\n\n- Submit a Pull Request: Go to the original `ActiveRecordAnonymizer` repository on GitHub, and you'll see a prompt to submit a pull request from your new branch.\n\n\nBug reports and pull requests are welcome on GitHub at https://github.com/keshavbiswa/active_record_anonymizer.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeshavbiswa%2Factive_record_anonymizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeshavbiswa%2Factive_record_anonymizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeshavbiswa%2Factive_record_anonymizer/lists"}