Selectively Seed Data From Seed.yml From Rails Console

Posted by Weston Ganger

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:

Article Topic:Software Development - Rails

Date:May 29, 2015

Recommended Posts

Contact

604-309-8713
info@solidfoundationwebdev.com

Send Me A Message

I would love to get in touch and talk about your next project. Feel free to send a message and I will get back to you shortly.

Get Connected