Rails

Selectively Seed Data From Seed.yml From Rails Console

Posted by Weston Ganger on May 29, 2015

I constantly find myself making a major change to a model and wanting to reseed only that models section from the seed.yml file in the rails console.

Open your rails console and run the following commands


seeds = YAML::load_file(Rails.root.join('db', 'seed.yml'))
Category.create!(seeds['categories'])

This will seed only the ‘categories’ section of the seed.yml file


Related External Links:


Posted in Rails and Tagged with rails ruby yaml seed 


Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts