mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-17 06:52:27 +01:00
adds a method to ActiveRecord::Base to dump a model to fixture
This commit is contained in:
parent
272400a889
commit
6bcc03834a
9
config/initializers/active_record_base.rb
Normal file
9
config/initializers/active_record_base.rb
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user