def self.to_fixture write_file(File.expand_path("test/fixtures/#{table_name}.yml", RAILS_ROOT), self.find(:all).inject("---\n") { |s, record| self.columns.inject(s+"#{record.id}:\n") { |s, c| s+" #{{c.name => record.attributes[c.name]}.to_yaml[5..-1]}\n" } }) end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Copy data from database into fixtures (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Rake task to load fixtures i... in ruby rails rake fixtures
» Typo under lighttpd in lighttpd ruby rails typo ruby-fcgi
» killing your own dispatch.fcgis in awk lighttpd ruby rails
» Howto Send Email When Rails... in email ruby rails exception error
» Handle Maintenance Tasks for... in ruby rails maintenance
» Typo current error in ruby rails typo error textdrive setup
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails