Create seed file from data already in the database
Solution 1:
There is a gem called seed_dump
, which will do exactly what you want:
- https://github.com/rroblak/seed_dump
- http://rubygems.org/gems/seed_dump
Solution 2:
Not sure about any existing rake tasks, but you can try running something like this in the rails console & paste the results into your seeds.rb file
(warning: dirty & untested)
c = Category.all
c.each do |cat|
puts "Category.create(:name => '#{cat.name}')"
end
Adjust for any additional fields you may have.
Hope this helps.