cryptogopher 3788f1a749 Fix db:seed:export task
* replace variable names with Hash to avoid invalid Ruby identifiers
* export all values as single-quoted to avoid string interpolation and
  treating BigDecimal numbers as Float
* #truncate table instead of #delete_all to avoid foreing_key
  constraints errors

Closes #56
2025-01-05 21:05:47 +01:00

10 lines
426 B
Plaintext

Unit.transaction do
ActiveRecord::Base.connection.truncate(Unit.table_name)
<% Unit.defaults.ordered.each do |unit| %>
<%= "\n" if unit.base.nil? %>
units['<%= unit.symbol %>'] =
Unit.create symbol: '<%= unit.symbol %>',<% unless unit.base.nil? %> base: units['<%= unit.base.symbol %>'], multiplier: '<%= unit.multiplier.to_scientific %>',<% end %>
description: '<%= unit.description %>'
<% end %>
end