diff --git a/config/initializers/active_record_base.rb b/config/initializers/active_record_base.rb new file mode 100644 index 000000000..f54d93090 --- /dev/null +++ b/config/initializers/active_record_base.rb @@ -0,0 +1,9 @@ +ActiveRecord::Base.class_eval do + def dump_fixture + fixture_file = "#{Rails.root}/test/fixtures/#{self.class.table_name}.yml" + File.open(fixture_file, "a") do |f| + f.puts({ "#{self.class.table_name.singularize}_#{id}" => attributes }. + to_yaml.sub!(/---\s?/, "\n")) + end + end +end