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

yaml_seeder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yaml_seeder

  • 0.1.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= YamlSeeder Seeds your ActiveRecord models from Foxy Fixture-like YAML files

== YAML seed files YamlSeeder works upon seed files which are very similar to fixtures - the foxy-fixtures introduced in Rails 2.0. For example, consider a Company model and an Employee model, where an employee belongs to a company:

=== companies.yml dunder: name: Dunder Mifflin

=== employees.yml michael: name: Michael Scott company: dunder

It's a good idea to put these seed files in their own directory, say "db/seeds".

For more information, google "foxy fixtures" or see http://ryandaigle.com/articles/2007/10/26/what-s-new-in-edge-rails-fixtures-just-got-a-whole-lot-easier

== Installation

gem install yaml_seeder

== Usage

Use YamlSeeder to seed your Rails database. If you're using Rails 2.3.4 or later, add the following to your "db/seeds.rb" file

===db/seeds.rb

Dir.glob(RAILS_ROOT + '/db/seeds/.yml').each do |file| YamlSeeder.seed('db/seeds', File.basename(file, '.')) end

Alternatively, or if you're using an earlier version of Rails, you can create a rake task (eg. called "db:yaml_seed"):

===lib/tasks/seed.rake

namespace :db do desc "Load seed files (from db/seeds) into the current environment's database." task :yaml_seed => :environment do Dir.glob(RAILS_ROOT + '/db/seeds/.yml').each do |file| YamlSeeder.seed('db/seeds', File.basename(file, '.')) end end end

== Notes

  • If ID's are not specified in the YAML seed files, then they will be assigned by the normal creation of saving an ActiveRecord (ie. the next ID available).
  • Currently, YamlSeeder only supports belong-to associations.

Copyright (c) 2010 Paul Fedory, released under the MIT license

FAQs

Package last updated on 28 Jan 2010

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