{"id":13878129,"url":"https://github.com/keshavbiswa/seedie","last_synced_at":"2025-07-16T14:31:27.460Z","repository":{"id":184875728,"uuid":"653125521","full_name":"keshavbiswa/seedie","owner":"keshavbiswa","description":"A ruby gem to run seeds for you in your Ruby on Rails application.","archived":false,"fork":false,"pushed_at":"2024-07-21T16:22:43.000Z","size":229,"stargazers_count":150,"open_issues_count":1,"forks_count":4,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-15T05:44:39.207Z","etag":null,"topics":["ruby","ruby-gem","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,"publiccode":null,"codemeta":null}},"created_at":"2023-06-13T13:01:42.000Z","updated_at":"2024-10-23T12:56:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"725174a0-e6cf-45ce-a430-86fbfa121e65","html_url":"https://github.com/keshavbiswa/seedie","commit_stats":null,"previous_names":["keshavbiswa/seedie"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Fseedie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Fseedie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Fseedie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keshavbiswa%2Fseedie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keshavbiswa","download_url":"https://codeload.github.com/keshavbiswa/seedie/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226138849,"owners_count":17579496,"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":["ruby","ruby-gem","ruby-on-rails"],"created_at":"2024-08-06T08:01:40.626Z","updated_at":"2024-11-24T07:30:47.235Z","avatar_url":"https://github.com/keshavbiswa.png","language":"Ruby","funding_links":[],"categories":["Ruby"],"sub_categories":[],"readme":"# Seedie\n\nSeedie is a Ruby gem designed to make it easy to seed your database with realistic data.\nUtilizing the Faker library, Seedie generates realistic data for ActiveRecord models.\nCurrently supports only PostrgreSQL and SQLite3 databases.\nThe gem includes a Rake task for seeding models and a Rails generator for easy setup.\n\n[![Gem Version](https://badge.fury.io/rb/seedie.svg)](https://badge.fury.io/rb/seedie)\n![Build Status](https://github.com/keshavbiswa/seedie/workflows/CI/badge.svg?branch=main)\n\n## Screencast\n\n[![Introducing Seedie](https://img.youtube.com/vi/3W0wRrOtsTk/0.jpg)](https://www.youtube.com/watch?v=3W0wRrOtsTk)\n\n## Installation\n\nAdd the following line to your application's Gemfile:\n\n```bash\ngem 'seedie'\n```\n\nAnd then execute:\n\n```bash\n$ bundle install\n```\n\nOr install it yourself as:\n\n```bash\n$ gem install seedie\n```\nNext, run the install generator:\n\n```bash\n$ rails generate seedie:install\n```\nThis will create a seedie.yml file in your config directory, which will include configurations for your models.\n\nAlternatively, you can also create a blank seedie.yml file by running:\n\n```bash\n$ rails generate seedie:install --blank\n```\n\nThis will generate a blank seedie.yml config file for you that you can now customize according to your needs.\n\n## Usage\n\n### Generating blank seedie.yml\nIf you want to create a blank seedie.yml file, use the `--blank` option:\n\n```bash\n$ rails generate seedie:install --blank\n```\n\nThis will generate a blank seedie.yml config file for you that you can now customize according to your needs.\n\n### Excluding Models\nIf you want to exclude certain models while generating the `seedie.yml`, use the `--excluded_models` option:\n\n```bash\n$ rails generate seedie:install --excluded_models User Admin Post\n```\n\nNOTE: Some models may not be excluded because of their dependencies. For example, if you have a model `Post` that belongs to a model `User`, then the `User` model will not be excluded even if you specify it in the `--excluded_models` option.\n\nYou'll get a warning in your console if any models are not excluded:\n\n```bash\nWARNING: User has dependencies with other models and cannot be excluded.\n```\n\n### Including only few Models\nIf you want to include only few particular models while generating the `seedie.yml`, use the `--include_only_models` option:\n\n```bash\n$ rails generate seedie:install --include_only_models Post Comment\n```\n\nNOTE: Some models may be a dependency for the required models and will need to be included for successful seeding. For example, if you have a model `Post` that belongs to a model `User`, then the `User` model will need to be included even if you didn't specify it in the `--include_only_models` option.\n\nYou'll get a warning in your console if any other models are included:\n\n```bash\nWARNING: User is a dependency of included models and needs to be included.\n```\n\n### Add Custom Attributes inside seedie.rb initializer\n\nWhile generating the seedie.yml file, there are default values.\nFor example, for every `string` field, the default value is `{{Faker::Lorem.word}}`.\nThis works fine for most attributes, but for some there are validations which breaks the seeding.\nTake `email` as an example, the default value `{{Faker::Lorem.word}}` will not be a valid email.\nBy default, when we generate the seedie.yml file, we add a `seedie.rb` initializer file in the `config/initializers` directory.\n\n```ruby\nSeedie.configure do |config|\n  # config.default_count = 10\n\n  config.custom_attributes[:email] = \"{{Faker::Internet.unique.email}}\"\n  # Add more custom attributes here\nend\n```\n\nThis ensures that the `email` field is seeded with a valid email address.\nYou can add more custom attributes in the `seedie.rb` initializer file.\n\n### Seeding Models\n\nTo seed your models, run the following Rake task:\n\n```bash\n$ rake seedie:seed\n```\n\nThis will use the configurations specified in seedie.yml to seed your models.\n\nThe seedie.yml file has entries for each model in your application, and you can customize the configuration for each one.\n\nHere's an example of a more advanced configuration in seedie.yml:\n\n\n```yaml\ndefault_count: 5\nmodels:\n  user:\n    attributes:\n      name: \"name {{index}}\"\n      email: \"{{Faker::Internet.email}}\"\n      address: \"{{Faker::Address.street_address}}\"\n    disabled_fields: [nickname password password_digest]\n  post:\n    count: 2\n    attributes:\n      title: \"title {{index}}\"\n      category:\n        values: [tech, sports, politics, entertainment]\n        options:\n          pick_strategy: random # or sequential\n    associations:\n      has_many:\n        comments: 4\n      belongs_to:\n        user: random # or new\n      has_one:\n        post_metadatum:\n          attributes:\n            seo_text: \"{{Faker::Lorem.paragraph}}\"\n      has_and_belongs_to_many:\n        tags:\n          count: 3\n          attributes:\n            name: \"{{Faker::Lorem.word}}\"\n    disabled_fields: []\n  comment:\n    attributes:\n      title: \"title {{index}}\"\n    associations:\n      belongs_to:\n        post:\n          attributes:\n            title: \"Comment Post {{index}}\"\n\n```\n\nIn this file:\n\n- `default_count` specifies the number of records to be generated for each model when no specific count is provided in the model's configuration.\n- `models` is a hash that contains a configuration for each model that should be seeded.\n- `attributes` is a hash that maps field names to the values that should be used. If attributes are not defined, Seedie will use Faker to generate a value for the field.\n  - The special `{{index}}` placeholder will be replaced by the index of the current record being created, starting from 1. This allows you to have unique values for each record.\n  - Additionally, we can use placeholders like `{{Faker::Internet.email}}` to generate dynamic and unique data for each record using Faker.\n  - We can also specify an array of values that can be picked from randomly or sequentially using the `values` and `pick_strategy` options.\n- `disabled_fields` is an array of fields that should not be automatically filled by Seedie.\n- `associations` specify how associated models should be generated. Here, `has_many`, `belongs_to`, `has_one` and `has_and_belongs_to_many` are supported.\n- The specified number for `has_many` represents the number of associated records to create.\n- For `belongs_to`, the value `random` means that a random existing record will be associated. If there is a unique index associated, then `unique` will be set or else `random` is the default.\n- If attributes are specified under an association, those attributes will be used when creating the associated record(s)\n- When using associations, it's important to define the models in the correct order in the `seedie.yml` file. Associated models should be defined before the models that reference them.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies.\nThen, run `bundle exec rspec` to run the tests.\nBy default, the tests will supress output of the seeds progress.\nUse `DEBUG_OUTPUT=true bundle exec rspec` to see the output of the seeds.\nYou can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/keshavbiswa/seedie.\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%2Fseedie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeshavbiswa%2Fseedie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeshavbiswa%2Fseedie/lists"}