Never been to TextSnippets 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)

Take from

  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+"#{}:\n") { |s, c|
          s+"  #{{ => record.attributes[]}.to_yaml[5..-1]}\n" }

You need to create an account or log in to post comments to this site.

Related Posts