Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

custom_seeds

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

custom_seeds

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

CustomSeeds

Seed file helpers for Rails applications.

Installation

Add this line to your application's Gemfile:

    gem 'custom_seeds'

And then execute:

$ bundle

Usage

Create a seedfile under db/seeds:

# db/seeds/users/followed_products.rb

CustomSeeds.define do
  title 'Followed Products'
  description 'Add followed products to user accounts'

  let(:products) { Product.validated.sample }

  before do
    FollowedProduct.destroy_all
  end

  records do
    User.all
  end

  each_record do |user|
    products.each do { |product| user.followed_products.create!(product: product) }
  end

  log_each do |user|
    "User #{user.email} followed #{user.followed_products.count} products"
  end
end

CLI

Run seeds using the rseed command:

$ rseed
$ rseed db/seeds/users/
$ rseed db/seeds/users/followed_products.rb

Run all seeds:

Rake

Run the file using the rake task:

$ rake db:seed:users:followed_products

Run all seeds using the rake task:

$ rake db:seed:all

FAQs

Package last updated on 20 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc