I have some data in my development database that I would like to utilize as fixtures in my test environment. What is the best way in Rails 2.x to export a database table to a YAML fixture?
Yaml is rather used for config purposes. It is not used for database such as MongoDB because serialization takes longer than json .
YAML is a popular programming language because it is human-readable and easy to understand. It can also be used in conjunction with other programming languages. Becuase of its flexibility and accessibility, YAML is used by the Ansible automation tool to create automation processes, in the form of Ansible Playbooks.
There is a rake task for this. You can specify RAILS_ENV if needed; the default is the development environment:
rake db:fixtures:dump # Create YAML test fixtures from data in an existing database.
I have been using YamlDb to save the state of my database.
Install it with the following command:
script/plugin install git://github.com/adamwiggins/yaml_db.git
Use the rake task to dump the contents of Rails database to db/data.yml
rake db:data:dump
Use the rake task to load the contents of db/data.yml into the database
rake db:data:load
This is the creators homepage:
http://blog.heroku.com/archives/2007/11/23/yamldb_for_databaseindependent_data_dumps/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With