Oops. Good thing I only had one user.

Posted by admin, Fri Jan 27 11:33:05 UTC 2006

Dump or Slurp YAML Reference Data (and Fixtures) | Ruby on Rails for Newbies

Sometimes you need to save data and use it again when you deploy a server or continue a project on a different machine.I wrote a plugin for ActiveRecord that lets you do this easily.
I really liked the idea of this plugin, but it could be a little more robust.

Just make sure that the first thing you try is “User.dump_to_file”. I used the “User.to_fixture” first, then I tried the “User.load_from_file”. And I got a nice users fixture file (which wiped out my existing fixture file without asking), and then…

$ script/runner "User.load_from_file"/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/runner.rb:27: ./script/../config/../vendor/plugins/ar_fixtures/lib/ar_fixtures.rb:12:in `initialize': No such file or directory - /Users/lori/rails/test/db/users.yml (Errno::ENOENT) from ./script/../config/../vendor/plugins/ar_fixtures/lib/ar_fixtures.rb:12:in `load_from_file' from (eval):1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `eval' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/runner.rb:27 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require' from script/runner:3 Lo and behold, it wiped out my USERS table. Oops.

Filed Under: | Tags:

Comments

Have your say

A name is required. You may use HTML in your comments.