snippet: saving data to a file to use as an input later

Posted by jacqui maher on March 04, 2008 at 01:41 PM

I find myself doing this often.

   1  >> data = Model.find_all_by_something("Something")
2 # => [... results...]
3
4 >> File.open("#{RAILS_ROOT}/db/data/somethings.yml", "w") do |f|
5 > f.puts data.to_yaml
6 > end

Hierarchy: previous, next

Comments

There are 2 comments on this post. Post yours →

I use ar_fixtures (http://nubyonrails.com/articles/dump-or-slurp-yaml-reference-data) for those tasks.

does this help me find me on those really cool maps !
?!?!

Post a comment

Required fields in bold.