Skip to content

Instantly share code, notes, and snippets.

@umar-webonise
Created March 31, 2015 14:34
Show Gist options
  • Save umar-webonise/0493ae93cd8d118bb0a8 to your computer and use it in GitHub Desktop.
Save umar-webonise/0493ae93cd8d118bb0a8 to your computer and use it in GitHub Desktop.
Seed Data for adding units for dynamice forms
unit_types = [
{ name: 'length' },
{ name: 'area' },
{ name: 'weight' },
{ name: 'volume' }
].each do |tag_info|
puts "Added #{UnitType.create(tag_info).inspect}"
end
UnitType.where(name: 'length').first.units.create(
[
{ name: 'inch'},
{ name: 'foot'},
{ name: 'meters'},
{ name: 'yard'},
{ name: 'mile'}
]
)
UnitType.where(name: 'area').first.units.create(
[
{ name: 'square metres'},
{ name: 'square centimetres'},
{ name: 'square millimetres'},
{ name: 'square miles'},
{ name: 'square yards'}
]
)
UnitType.where(name: 'volume').first.units.create(
[
{ name: 'cubic metres'},
{ name: 'cubic centimetres'},
{ name: 'cubic millimetres'},
{ name: 'cubic miles'},
{ name: 'cubic yards'}
]
)
UnitType.where(name: 'weight').first.units.create(
[
{ name: 'kg'},
{ name: 'mg'}
]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment