I''m looking for a way to slurp or dump a table to a yml file. I have found several ''backup'' procedures but they cause problems with my join tables and I just want to dump a couple of the join tables anyway. Is there some easy way to do this? Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I just tried this in script/console: $ ./script/console Loading development environment (Rails 2.0.2)>> File.open "users.txt", "w" do |file|?> User.all.each do |user| ?> file.write user.to_yaml>> end >> end=> [...bunch of users...]>> exit$ ls Capfile app/ data/ doc/ lib/ public/ spec/ test/ users.txt Rakefile config/ db/ flex/ log/ script/ stories/ tmp/ vendor/ $ The file was created at the root of my rails app. I don''t know if there are better ways to do it, but that was certainly quick. Regards, Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, 2008-05-28 at 14:32 -0400, Craig Demyanovich wrote:> I just tried this in script/console: > > $ ./script/console > Loading development environment (Rails 2.0.2) > >> File.open "users.txt", "w" do |file| > ?> User.all.each do |user| > ?> file.write user.to_yaml > >> end > >> end > => [...bunch of users...] > >> exit > $ ls > Capfile app/ data/ doc/ lib/ public/ > spec/ test/ users.txt > Rakefile config/ db/ flex/ log/ script/ > stories/ tmp/ vendor/ > $ > > The file was created at the root of my rails app. I don''t know if > there are better ways to do it, but that was certainly quick.---- gotcha...nice...thanks Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, 2008-05-28 at 14:32 -0400, Craig Demyanovich wrote:> I just tried this in script/console: > > $ ./script/console > Loading development environment (Rails 2.0.2) > >> File.open "users.txt", "w" do |file| > ?> User.all.each do |user| > ?> file.write user.to_yaml > >> end > >> end > => [...bunch of users...] > >> exit > $ ls > Capfile app/ data/ doc/ lib/ public/ > spec/ test/ users.txt > Rakefile config/ db/ flex/ log/ script/ > stories/ tmp/ vendor/ > $ > > The file was created at the root of my rails app. I don''t know if > there are better ways to do it, but that was certainly quick.---- this works except for one thing...each record is written like this... --- !ruby/object:Right attributes: name: Personnel Admin action: index id: "1" controller: assessments --- !ruby/object:Right attributes: name: Personnel Admin action: find id: "2" controller: assessments so each item has the same identifier and you cannot use it without modification. I suppose I could figure out a way with sed but this doesn''t quite work as well as I had hoped. Thanks Craig --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---