Skip to content

Instantly share code, notes, and snippets.

@WaYdotNET
Created September 20, 2010 08:00
Show Gist options
  • Save WaYdotNET/587572 to your computer and use it in GitHub Desktop.
Save WaYdotNET/587572 to your computer and use it in GitHub Desktop.
DataMapper.auto_migrate!
(1..5).each do |n|
PlantType.create(:nome => "nome_#{n}")
ComponentType.create(:nome => "nome_#{n}")
Supplier.create(:nome => "nome_#{n}")
Component.create(:nome => "nome_#{n}", :supplier => Supplier.first, :component_type => ComponentType.first)
end
params = {:supplier=> Supplier.get(1), :component_type => ComponentType.get(1), :nome => "ciao", :plant_types => PlantType.all(:id => "3,4".split(","))}
component = Component.first
component.update(params)
params = {:supplier=> Supplier.get(1), :component_type => ComponentType.get(1), :nome => "ciao", :plant_types => PlantType.all(:id => "3,1".split(","))}
component = Component.first
component.update(params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment