Reputation: 797
How do you convert an sqlite database (generated by Rails) to a collection of JSON objects? Is there a set of scripts/ a ruby gem that does that, or is it necessary to code something from scratch?
Upvotes: 1
Views: 1965
Reputation: 6501
I'm not sure that I fully understand the question, but here's a stab.
If you have a collection called Widgets, you can call Widgets.all.to_json
This is trivial to do in a Rails Console session.
You can then simply output that to where every you like, such as a text file.
Other ways would be to use a db dump task via rake rake -T
will show you the available commands.
Upvotes: 1